Querying Logs of a Specified Task in a Training Job
Function
This API is used to obtain the real-time run logs of a specified training job task on ModelArts.
This API is used in the following scenario: When you need to view the run logs of a specific training job task to locate faults or monitor the training progress, you can use this API to obtain the log content. Before using this API, ensure that you have obtained the training job ID and task ID and have the permission to view logs. After the query is complete, the platform returns the log content, start and end line numbers, and other information. If the training job ID or task ID does not exist, no task log is generated, or you do not have the operation permission, the API will return an error message.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
modelarts:trainJob:getLogs
Read
trainJob *
g:ResourceTag/<tag-key>
modelarts:trainJob:get
-
-
g:EnterpriseProjectId
URI
GET /v2/{project_id}/training-jobs/{training_job_id}/logs/{task_id}
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition: Project ID. For details, see Obtaining a Project ID and Name. Constraints: N/A Range: The value can contain 1 to 64 characters. Only letters, digits, and hyphens (-) are allowed. Default Value: N/A |
| training_job_id | Yes | String | Definition: Training job ID. For details, see Obtaining Training Jobs. Constraints: N/A Range: N/A Default Value: N/A |
| task_id | Yes | String | Definition: Task ID of a training job. You can obtain the value from the status.tasks field in the training job details. Constraints: N/A Range: For a single node, the default value is worker-0. For multiple nodes, the value is worker-0, worker-1, and so on. Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| base_line | No | String | Definition: Baseline line number for log query, used for pagination query. Constraints: N/A Range: N/A Default Value: N/A (queries starting from the latest logs). |
| lines | No | Integer | Definition: Number of returned log lines. Constraints: N/A Range: 1 to 500 Default Value: 50 |
| order | No | String | Definition: Log sorting mode. Constraints: N/A Range: Default Value: desc |
Request Parameters
None
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| start_line | String | Definition: Start line number of the returned log. Range: N/A |
| end_line | String | Definition: End line number of the returned log. Range: N/A |
| lines | Integer | Definition: Number of returned log lines. Range: N/A |
| content | String | Definition: Log content. Range: N/A |
Example Requests
Query the logs of worker-0 of the training job whose UUID is 2cd88daa-31a4-40a8-a58f-d186b0e93e4f.
GET https://{endpoint}/v2/{project_id}/training-jobs/2cd88daa-31a4-40a8-a58f-d186b0e93e4f/logs/worker-0 Example Responses
Status code: 200
{
"start_line" : "123",
"end_line" : "173",
"lines" : 50,
"content" : "[ModelArts Service Log][INFO][2021/05/18 14:28:14,207]:\n output-handler finalizing due to: [training finished]\n[ModelArts Service Log][INFO][2021/05/18 14:28:14,207]:\n output-handler finalized"
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Response body for querying training job logs. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot