Updated on 2024-03-21 GMT+08:00

Querying Training Job Logs

Sample Code

In ModelArts notebook, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see Session Authentication.

  • Method 1: Use the specified job_id and version_id.
    1
    2
    3
    4
    5
    6
    from modelarts.session import Session
    from modelarts.estimator import Estimator
    session = Session()
    estimator = Estimator(modelarts_session=session, job_id="182626", version_id="278813")
    job_log = estimator.get_job_log(log_file='job-job-0713-191758.0')
    print(job_log)
    
  • Method 2: Use the training job created in Creating a Training Job.
    1
    2
    job_log = job_instance.get_job_log(log_file='job-job-0713-191758.0')
    print(job_log)
    

Parameters

Table 1 Estimator request parameters

Parameter

Mandatory

Type

Description

modelarts_session

Yes

Object

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

job_id

Yes

String

ID of a training job. You can query job_id using the training job object generated in Creating a Training Job, for example, job_instance.job_id, or from the response obtained in Querying the List of Training Jobs.

version_id

Yes

String

Version ID of a training job. You can query version_id using the training job object generated in Creating a Training Job, for example, job_instance.version_id, or from the response obtained in Querying the List of Training Jobs.

Table 2 get_job_log request parameters

Parameter

Mandatory

Type

Description

log_file

Yes

String

Name of a training job log file

start_byte

No

Long

Start position for obtaining the log. The default value is 0. The value range is [-1, +∞]. If the value is -1, the log with the latest offset is obtained.

offset

No

Long

Length of the obtained log. The default value is 2048. The value range is [-2048, 2048].

Table 3 get_job_log response parameters

Parameter

Type

Description

error_msg

String

Error message when the API call fails.

This parameter is not included when the API call succeeds.

error_code

String

Error code when the API fails to be called. For details, see Error Codes.

This parameter is not included when the API call succeeds.

content

String

Content of the requested log

lines

Integer

Number of lines in the log

start_line

String

Start position of the obtained log

end_line

String

End position of the obtained log