Help Center/ ModelArts/ API Reference/ Training Management/ Querying the Algorithm List
Updated on 2024-05-30 GMT+08:00

Querying the Algorithm List

Function

This API is used to query the algorithm list.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

GET /v2/{project_id}/algorithms

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

offset

No

Integer

Offset for querying algorithms. The minimum value is 0. For example, if this parameter is set to 1, the query starts from the second one.

limit

No

Integer

Limit of algorithms to be queried. The value ranges from 1 to 50.

sort_by

No

String

Metric for sorting algorithms to be queried. create_time is used by default.

order

No

String

Order of queried algorithms. The default value is desc, indicating that queried algorithms are sorted in descending order. You can also select asc to sort the records in ascending order.

group_by

No

String

Condition for grouping the algorithms to be queried.

searches

No

String

Filter criteria for algorithms to be queried, for example, fuzzy match by the algorithm name.

workspace_id

No

String

Workspace ID.

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

total

Integer

Total number of queried algorithms of the current user.

count

Integer

Total number of algorithms that meet the search criteria of the current user.

limit

Integer

Maximum number of queried algorithms of the current user.

offset

Integer

Offset of all algorithm queries of the current user.

sort_by

String

Fields used to sort queried algorithms of the current user.

order

String

Order of queried algorithms of the current user. The default value is desc, indicating the descending order. You can also set this parameter to asc, indicating the ascending order.

group_by

String

Grouping mode of queried algorithms of the current user.

items

Array of AlgorithmResponse objects

Details about all algorithms that meet the search criteria of the current user.

Table 4 AlgorithmResponse

Parameter

Type

Description

metadata

metadata object

Algorithm metadata, which describes basic algorithm information.

job_config

job_config object

Algorithm configuration, such as the boot file.

resource_requirements

Array of resource_requirements objects

Algorithm resource constraint. This parameter is optional. After this parameter is set, the console filters available public resource pools when the algorithm is used in training jobs.

advanced_config

advanced_config object

Advanced algorithm policy:

  • auto_search

Table 5 metadata

Parameter

Type

Description

id

Integer

Algorithm UUID. You do not need to set this parameter when creating an algorithm.

name

String

Algorithm name. The value must contain 1 to 64 characters consisting of only digits, letters, underscores (_), and hyphens (-).

description

String

Description of the algorithm. The value is a string of [0, 256] characters. The default value is NULL.

workspace_id

String

Workspace where a specified algorithm is located. The default value is 0. The value 0 indicates the default workspace.

ai_project

String

AI project to which a specified algorithm belongs. The default value is default-ai-project. The AI project has been brought offline. Ignore it.

user_name

String

Username.

domain_id

String

Domain ID of a user.

source

String

Algorithm source.

api_version

String

Algorithm API version, which identifies the old and new ones.

is_valid

String

Algorithm availability.

state

String

Algorithm state.

tags

Array of Map<String,String> objects

Algorithm tags.

attr_list

Array of strings

Algorithm attribute list.

version_num

Integer

Number of algorithm versions. The default value is 0.

size

Integer

Algorithm size.

create_time

Long

Timestamp when the algorithm is created.

update_time

Long

Timestamp when the algorithm is updated.

Table 6 job_config

Parameter

Type

Description

code_dir

String

Algorithm code directory, for example, /usr/app/. This parameter must be used together with boot_file.

boot_file

String

Code boot file of the algorithm, which must be stored in the code directory, for example, /usr/app/boot.py. This parameter must be used with code_dir.

command

String

Container startup command of a custom image algorithm.

parameters

Array of Parameter objects

Running parameter of an algorithm.

inputs

Array of inputs objects

Data input of an algorithm.

outputs

Array of outputs objects

Data output of an algorithm.

engine

engine object

Algorithm engine.

code_tree

Array of code_tree objects

Algorithm directory tree

parameters_customization

Boolean

Whether the algorithm allows hyperparameter customization during training job creation.

Table 7 Parameter

Parameter

Type

Description

name

String

Parameter name.

value

String

Parameter value.

description

String

Parameter description.

constraint

constraint object

Parameter constraint.

i18n_description

i18n_description object

Internationalization description.

Table 8 constraint

Parameter

Type

Description

type

String

Parameter type.

editable

Boolean

Whether the parameter is editable.

required

Boolean

Whether the parameter is mandatory.

sensitive

Boolean

Whether the parameter is sensitive This function is not implemented currently.

valid_type

String

Valid type.

valid_range

Array of strings

Valid range.

Table 9 i18n_description

Parameter

Type

Description

language

String

Language. Options:

  • zh-cn: Chinese

  • en-us: English

description

String

Description.

Table 10 inputs

Parameter

Type

Description

name

String

Name of the data input channel.

description

String

Description of the data input channel.

remote_constraints

Array of remote_constraints objects

Data input constraint.

Table 11 remote_constraints

Parameter

Type

Description

data_type

String

Data input type, including the data storage location and dataset.

attributes

Array of Map<String,String> objects

Attributes when the data input type is a dataset. Enums:

  • data_format: data format

  • data_segmentation: data segmentation

  • dataset_type: data labeling

Table 12 outputs

Parameter

Type

Description

name

String

Name of the data output channel.

description

String

Description of the data output channel.

Table 13 engine

Parameter

Type

Description

engine_id

String

Engine ID selected for an algorithm.

engine_name

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

engine_version

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

image_url

String

Custom image URL selected by an algorithm.

Table 14 code_tree

Parameter

Type

Description

name

String

Name of the current directory in the algorithm directory tree.

children

Object

Subfiles and subdirectories in the current directory of the algorithm directory tree.

Table 15 resource_requirements

Parameter

Type

Description

key

String

Resource constraint. The options are as follows:

  • flavor_type: flavor type, which can be CPU, Ascend, or GPU.

  • device_distributed_mode: whether to support multi-card training. The value can be multiple (supported) or singular (not supported).

  • host_distributed_mode: whether to support distributed training. The value can be multiple (supported) or singular (not supported).

value

Array of strings

Value of the resource constraint key.

operator

String

Relationship between keys and values. Currently, only in is supported. For example, flavor_type in [CPU,GPU].

Table 16 advanced_config

Parameter

Type

Description

auto_search

auto_search object

Hyperparameter search policy.

Table 18 reward_attrs

Parameter

Type

Description

name

String

Metric name.

mode

String

Search mode.

  • max: A larger metric value is preferred.

  • min: A smaller metric value is preferred.

regex

String

Regular expression of a metric.

Table 19 search_params

Parameter

Type

Description

name

String

Hyperparameter name.

param_type

String

Parameter type.

  • continuous: The hyperparameter is of the continuous type. When an algorithm is used in a training job, continuous hyperparameters are displayed as text boxes on the console.

  • discrete: The hyperparameter is of the discrete type. When an algorithm is used in a training job, discrete hyperparameters are displayed as drop-down lists on the console.

lower_bound

String

Lower bound of the hyperparameter.

upper_bound

String

Upper bound of the hyperparameter.

discrete_points_num

String

Number of discrete points of a continuous hyperparameter.

discrete_values

String

List of discrete hyperparameter values.

Table 20 algo_configs

Parameter

Type

Description

name

String

Name of the search algorithm.

params

Array of AutoSearchAlgoConfigParameter objects

Search algorithm parameters.

Table 21 AutoSearchAlgoConfigParameter

Parameter

Type

Description

key

String

Parameter key.

value

String

Parameter value.

type

String

Parameter type.

Example Requests

The following shows how to query all algorithms in jobs whose names contain TestModelArtsalgorithm and maximum number of algorithms is set to 1.

GET https://endpoint/v2/{project_id}/algorithms?limit=1&searches=name%3ATestModelArtsalgorithm

Example Responses

Status code: 200

ok

{
  "total" : 1,
  "count" : 1,
  "limit" : 1,
  "offset" : 0,
  "sort_by" : "create_time",
  "order" : "desc",
  "group_by" : "",
  "items" : [ {
    "metadata" : {
      "id" : "2e5451fe-913f-4492-821a-2981031382f7",
      "name" : "TestModelArtsalgorithm",
      "description" : "This is a ModelArts algorithm",
      "create_time" : 1636600721742,
      "workspace_id" : "0",
      "ai_project" : "default-ai-project",
      "user_name" : "",
      "domain_id" : "xxxxxxxxxxxxxxxxxxxxxxxxxx",
      "source" : "custom",
      "api_version" : "",
      "is_valid" : true,
      "state" : "",
      "size" : 4791,
      "tags" : null,
      "attr_list" : null,
      "version_num" : 0,
      "update_time" : 0
    },
    "job_config" : {
      "code_dir" : "/algo-test/pytorch/work1/code/",
      "boot_file" : "/algo-test/pytorch/work1/code/test-pytorch.py",
      "command" : "",
      "parameters" : [ {
        "name" : "test-parameter",
        "description" : "",
        "i18n_description" : null,
        "value" : "10",
        "constraint" : {
          "type" : "String",
          "editable" : true,
          "required" : false,
          "sensitive" : false,
          "valid_type" : "None",
          "valid_range" : [ ]
        }
      } ],
      "parameters_customization" : true,
      "inputs" : [ {
        "name" : "data_url",
        "description" : "name to translate"
      } ],
      "outputs" : [ {
        "name" : "train_url",
        "description" : "name to translate"
      } ],
      "engine" : {
        "engine_id" : "pytorch-cp36-1.3.0",
        "engine_name" : "PyTorch",
        "engine_version" : "PyTorch-1.3.0-python3.6"
      },
      "code_tree" : {
        "name" : "code/",
        "children" : [ {
          "name" : "test-pytorch.py"
        } ]
      }
    },
    "resource_requirements" : null,
    "advanced_config" : { }
  } ]
}

Status Codes

Status Code

Description

200

ok

Error Codes

See Error Codes.