snowflake.ml.jobs.MLJobDefinition

class snowflake.ml.jobs.MLJobDefinition(source: Union[str, Callable[[_Args], _ReturnValue]], compute_pool: str, stage_name: str, session: Optional[Session] = None, name: Optional[str] = None, target_instances: int = 1, min_instances: Optional[int] = None, external_access_integrations: Optional[list[str]] = None, env_vars: Optional[dict[str, str]] = None, spec_overrides: Optional[dict[str, Any]] = None, enable_metrics: bool = True, query_warehouse: Optional[str] = None, runtime_environment: Optional[str] = None, overwrite: bool = False, arg_protocol: ArgProtocol = ArgProtocol.NONE, default_args: Optional[list[Any]] = None, database: Optional[str] = None, schema: Optional[str] = None, payload: Optional[JobPayload] = None)

Bases: Generic[_Args, _ReturnValue], SerializableSessionMixin

Methods

delete() None
classmethod register(source: Union[str, Callable[[_Args], _ReturnValue]], compute_pool: str, stage_name: str, session: Optional[Session] = None, **kwargs: Any) MLJobDefinition[_Args, _ReturnValue]

Create and register a new MLJobDefinition instance eagerly.

Parameters:
  • source – The source for the job definition. Can be: - A string path to a local directory or file or stage directory path containing Python script(s). - A callable (function) to be executed as the job.

  • compute_pool – The compute pool to use for the job.

  • stage_name – The name of the stage where the job payload will be uploaded.

  • session – The Snowpark session to use. If none specified, uses active session.

  • kwargs

    Additional keyword arguments. Supported arguments: entrypoint (str): The entry point for job execution. Can be:

    • A string path to the entry point script inside the source directory. Required when source is a directory with multiple entry points.

    • A list of strings representing a custom command (e.g., [“arctic_training”]) which is passed through as-is without local resolution or validation. This is useful for entrypoints that are installed via pip_requirements.

    target_instances (int): The number of nodes in the job. Defaults to 1. min_instances (int): The minimum number of nodes required to start the job.

    If none specified, defaults to target_instances.

    pip_requirements (list[str]): A list of pip requirements for the job. external_access_integrations (list[str]): A list of external access integrations. env_vars (dict): Environment variables to set in container. enable_metrics (bool): Whether to enable metrics publishing for the job. Defaults to True. query_warehouse (str): The query warehouse to use. Defaults to session warehouse. spec_overrides (dict): A dictionary of overrides for the service spec. imports (list[Union[tuple[str, str], tuple[str]]]): A list of additional payloads used in the job. runtime_environment (str): The runtime image to use. Only support image tag or full image URL,

    e.g. “1.7.1” or “image_repo/image_name:image_tag”. When it refers to a full image URL, it should contain image repository, image name and image tag.

    name (str): The name of the job definition. If not specified, a name will be generated

    based on the entrypoint file name or function name.

    overwrite (bool): Whether to overwrite an existing job definition with the same name.

    Defaults to False.

    database (str): The database to use for the job definition. schema (str): The schema to use for the job definition. default_args (list): Default arguments to pass to the job on each invocation. arg_protocol (ArgProtocol): The argument protocol to use for passing arguments.

Returns:

An MLJobDefinition instance representing the registered job definition.

This function or method is in private preview since 1.26.0.

to_sql(*, job_args: Optional[list[Any]] = None, use_async: bool = False) str

Attributes

session