Updated on 2022-11-24 GMT+08:00

Querying a Dataset List

Obtain a dataset list by page.

list_datasets(session, dataset_type=None, dataset_name=None, offset=None, limit=None)

Sample Code

  • Example 1: Obtain a dataset list.
    from modelarts.session import Session
    from modelarts.dataset import Dataset
    session = Session()
    # Obtain a dataset list.
    dataset_list = Dataset.list_datasets(session)
    print(dataset_list) # Print the query result.
  • Example 2: Obtain a dataset list by dataset type.
    # Obtain image classification datasets.
    dataset_list = Dataset.list_datasets(session, dataset_type=0)
    print(dataset_list)
  • Example 3: Obtain a dataset list by dataset name.
    # Obtain the datasets with dataset contained in dataset names.
    dataset_list = Dataset.list_datasets(session, dataset_name="dataset")
    print(dataset_list)
  • Example 4: Obtain a dataset list by page.
    # By default, 10 dataset records are returned at a time. You can set limit and offset for query by page.
    dataset_list = Dataset.list_datasets(session, offset=0, limit=50) # Obtain the 1st to 50th records.
    print(dataset_list)
    dataset_list = Dataset.list_datasets(session, offset=1, limit=50) # Obtain the 51st to 100th records.
    print(dataset_list)

Parameters

Table 1 Request parameters

Name

Mandatory

Type

Description

session

Yes

Object

Session object. For details about the initialization method, see Session Authentication.

dataset_type

No

Integer

Obtain a dataset list by dataset type. By default, this parameter is left blank. The options are as follows:

  • 0: image classification
  • 1: object detection
  • 3: image segmentation
  • 100: text classification
  • 101: named entity recognition
  • 102: text triplet
  • 200: sound classification
  • 201: speech content
  • 202: speech paragraph labeling
  • 400: table dataset
  • 600: video labeling
  • 900: custom format

dataset_name

No

String

Fuzzy search keyword. By default, this parameter is left blank.

offset

No

Integer

Start page for pagination display. The default value is 0.

limit

No

Integer

Maximum number of records returned on each page. The value ranges from 1 to 100. The default value is 10.