snowflake.ml.jobs.MLJob¶
- class snowflake.ml.jobs.MLJob(id: str, service_spec: Optional[dict[str, Any]] = None, session: Optional[Session] = None)¶
Bases:
Generic
[T
]Methods
- get_logs(limit: int = - 1, instance_id: Optional[int] = None, *, as_list: Literal[True]) list[str] ¶
- get_logs(limit: int = - 1, instance_id: Optional[int] = None, *, as_list: Literal[False] = False) str
Return the job’s execution logs.
- Parameters:
limit – The maximum number of lines to return. Negative values are treated as no limit.
instance_id – Optional instance ID to get logs from a specific instance. If not provided, returns logs from the head node.
as_list – If True, returns logs as a list of lines. Otherwise, returns logs as a single string.
- Returns:
The job’s execution logs.
- result(timeout: float = - 1) T ¶
Block until completion. Returns job execution result.
- Parameters:
timeout – The maximum time to wait in seconds. Negative values are treated as no timeout.
- Returns:
The deserialized job result. # noqa: DAR401
- Return type:
T
- Raises:
RuntimeError – If the job failed or if the job doesn’t have a result to retrieve.
TimeoutError – If the job does not complete within the specified timeout. # noqa: DAR402
This function or method is in private preview since 1.8.2.
- show_logs(limit: int = - 1, instance_id: Optional[int] = None) None ¶
Display the job’s execution logs.
- Parameters:
limit – The maximum number of lines to display. Negative values are treated as no limit.
instance_id – Optional instance ID to get logs from a specific instance. If not provided, displays logs from the head node.
- wait(timeout: float = - 1) Literal['PENDING', 'RUNNING', 'FAILED', 'DONE', 'INTERNAL_ERROR'] ¶
Block until completion. Returns completion status.
- Parameters:
timeout – The maximum time to wait in seconds. Negative values are treated as no timeout.
- Returns:
The job’s completion status.
- Raises:
TimeoutError – If the job does not complete within the specified timeout.
Attributes
- id¶
Get the unique job ID
- name¶
- num_instances¶
- status¶
Get the job’s execution status.