Updated on 2024-05-30 GMT+08:00

Querying a Training Job List

Function

This API is used to obtain the created training jobs that meet the search criteria.

URI

GET /v1/{project_id}/training-jobs

Table 1 describes the required parameters.
Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID and Name.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

status

No

String

Job status. By default, all job statuses are returned. For example, to obtain failed jobs, set the value of status to 3, 5, 6, or 13. For details about the job statuses, see Job Statuses.

per_page

No

Integer

Number of jobs displayed on each page. The value range is [1, 1000]. Default value: 10

page

No

Integer

Index of the page to be queried. Default value: 1 The value range is [1, 65535].

sortBy

No

String

Sorting mode of the query. The value can be job_name, job_desc, status, duration, version_count, or create_time. Default value: job_name

order

No

String

Sorting order. Options:

  • asc: ascending order. It is the default value.
  • desc: descending order

search_content

No

String

Search content, for example, a training job name. The value must contain 0 to 64 characters. By default, this parameter is left blank.

workspace_id

No

String

Workspace where a job resides. Default value: 0

Request Body

None

Response Body

Table 3 describes the response parameters.
Table 3 Parameters

Parameter

Type

Description

is_success

Boolean

Whether the request is successful

error_message

String

Error message of a failed API call.

This parameter is not included when the API call succeeds.

error_code

String

Error code of a failed API call. For details, see Error Codes.

This parameter is not included when the API call succeeds.

job_total_count

Integer

Total number of created jobs

job_count_limit

Integer

Number of training jobs that can be created

jobs

jobs array

Attributes of a training job. For details, see Table 4.

quotas

Integer

Maximum number of training jobs

Table 4 jobs parameters

Parameter

Type

Description

job_id

Long

ID of a training job

job_name

String

Name of a training job

version_id

Long

Version ID of a training job

status

Int

Status of a training job. For details about the job statuses, see Job Statuses.

create_time

Long

Timestamp when a training job is created

duration

Long

Training job running duration, in milliseconds

job_desc

String

Description of a training job

version_count

Long

Number of versions of a training job

Sample Request

The following shows how to obtain training jobs in the 7 state and with name containing job on the first page. Each page displays 10 records sorted by job_name in ascending order.

GET    https://endpoint/v1/{project_id}/training-jobs?status=7&per_page=10&page=1&sortBy=job_name&order=asc&search_content=job

Sample Response

  • Successful response
    {
        "is_success": true,
        "quotas": 5,
        "job_total_count": 1,
        "job_count_limit": 3,
        "jobs": [
            {
                "job_id": 10,
                "job_name": "testModelArtsJob",
                "version_id": 10,
                "status": 10,
                "create_time": 1524189990635,
                "duration": 532003,
                "job_desc": "This is ModelArts job",
                "version_count": 5
            }
        ]
    }
  • Failed response
    {
        "is_success": false,
        "error_message": "Error string",
        "error_code": "ModelArts.0105"
    
    }

Status Code

For details about the status code, see Status Code.