On this page

Obtaining Training Logs

Updated on 2024-06-12 GMT+08:00

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.
    from modelarts.session import Session
    from modelarts.estimatorV2 import Estimator
    session = Session()
    estimator = Estimator(session=session, job_id="your job id")
    info = estimator.get_job_log()
    print(info)
  • Method 2: Use the training job created in Creating a Training Job.
    log = job_instance.get_job_log(task_id="worker-0")
    print(log)

Parameters

Table 1 Parameters for initializing the Estimator

Parameter

Mandatory

Type

Description

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 obtain job_id using the training job created in Creating a Training Job, for example, job_instance.job_id, or from the response obtained in Obtaining Training Jobs.

Table 2 get_job_log request parameters

Parameter

Mandatory

Type

Description

task_id

No

String

ID of a worker node for obtaining logs. It defaults to worker-0. If train_instance_count is set to 2 when you create a training job, the value of this parameter can be worker-0 or worker-1.

Table 3 Response parameters

Parameter

Type

Description

content

String

Log content

  • If the size of the log file does not exceed the limit allowed (n MB), all logs are returned.
  • If the size of the log file exceeds the limit allowed (n MB), the latest n MB logs are returned.

current_size

Integer

Size of the returned log file, in bytes. The maximum value is 5 MB.

full_size

Integer

Size of a complete log file, in bytes.

Table 4 Response for the failure to call a training API

Parameter

Type

Description

error_msg

String

Error message when calling an API failed. This parameter is unavailable if an API is successfully called.

error_code

String

Error code when calling an API failed. For details, see "Error Codes" in ModelArts API Reference. This parameter is unavailable if an API is successfully called.

error_solution

String

Solution to an API calling failure. This parameter is unavailable if an API is successfully called.

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback