Remote function classes and methods specification — sagemaker 2.247.0 documentation (original) (raw)

@remote decorator

client.remote(*, dependencies=None, pre_execution_commands=None, pre_execution_script=None, environment_variables=None, image_uri=None, include_local_workdir=None, custom_file_filter=None, instance_count=1, instance_type=None, job_conda_env=None, job_name_prefix=None, keep_alive_period_in_seconds=0, max_retry_attempts=1, max_runtime_in_seconds=86400, role=None, s3_kms_key=None, s3_root_uri=None, sagemaker_session=None, security_group_ids=None, subnets=None, tags=None, volume_kms_key=None, volume_size=30, encrypt_inter_container_traffic=None, spark_config=None, use_spot_instances=False, max_wait_time_in_seconds=None, disable_output_compression=False, use_torchrun=False, use_mpirun=False, nproc_per_node=None)

Decorator for running the annotated function as a SageMaker training job.

This decorator wraps the annotated code and runs it as a new SageMaker job synchronously with the provided runtime settings.

If a parameter value is not set, the decorator first looks up the value from the SageMaker configuration file. If no value is specified in the configuration file or no configuration file is found, the decorator selects the default as specified below. For more information, seeConfiguring and using defaults with the SageMaker Python SDK.

Parameters:

RemoteExecutor

class sagemaker.remote_function.RemoteExecutor(*, dependencies=None, pre_execution_commands=None, pre_execution_script=None, environment_variables=None, image_uri=None, include_local_workdir=None, custom_file_filter=None, instance_count=1, instance_type=None, job_conda_env=None, job_name_prefix=None, keep_alive_period_in_seconds=0, max_parallel_jobs=1, max_retry_attempts=1, max_runtime_in_seconds=86400, role=None, s3_kms_key=None, s3_root_uri=None, sagemaker_session=None, security_group_ids=None, subnets=None, tags=None, volume_kms_key=None, volume_size=30, encrypt_inter_container_traffic=None, spark_config=None, use_spot_instances=False, max_wait_time_in_seconds=None, disable_output_compression=False, use_torchrun=False, use_mpirun=False, nproc_per_node=None)

Run Python functions asynchronously as SageMaker jobs

Constructor for RemoteExecutor

If a parameter value is not set, the constructor first looks up the value from the SageMaker configuration file. If no value is specified in the configuration file or no configuration file is found, the constructor selects the default as specified below. For more information, see Configuring and using defaults with the SageMaker Python SDK.

Parameters:

submit(func, *args, **kwargs)

Execute the input function as a SageMaker job asynchronously.

Parameters:

map(func, *iterables)

Return an iterator that applies function to every item of iterable, yielding the results.

If additional iterables arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted.

Parameters:

shutdown()

Prevent more function executions to be submitted to this executor.

Future

class sagemaker.remote_function.client.Future

Class representing a reference to a SageMaker job result.

Reference to the SageMaker job created as a result of the remote function run. The job may or may not have finished running.

static from_describe_response(describe_training_job_response, sagemaker_session)

Construct a Future from a describe_training_job_response object.

result(timeout=None)

Returns the SageMaker job result.

This method waits for the SageMaker job created from the remote function execution to complete for up to the timeout value (if specified). If timeout is None, this method will wait until the SageMaker job completes.

Parameters:

timeout (float) – Timeout in seconds to wait until the job is completed. None by default.

Returns:

The Python object returned by the remote function.

Return type:

Any

wait(timeout=None)

Wait for the underlying SageMaker job to complete.

This method waits for the SageMaker job created as a result of the remote function run to complete for up to the timeout value (if specified). If timeout is None, this method will block until the job is completed.

Parameters:

timeout (int) – Timeout in seconds to wait until the job is completed before it is stopped. Defaults to None.

Returns:

None

Return type:

None

cancel()

Cancel the function execution.

This method prevents the SageMaker job being created or stops the underlying SageMaker job early if it is already in progress.

Returns:

True if the underlying SageMaker job created as a result of the remote function run is cancelled.

Return type:

bool

running()

Check if the underlying SageMaker job is running.

Returns:

True if the underlying SageMaker job is still running. False, otherwise.

Return type:

bool

cancelled()

Check if the underlying SageMaker job was cancelled.

Returns:

True if the underlying SageMaker job was cancelled. False, otherwise.

Return type:

bool

done()

Check if the underlying SageMaker job is finished.

Returns:

True if the underlying SageMaker job finished running. False, otherwise.

Return type:

bool

client.list_futures(sagemaker_session=None)

Generates Future objects with information about jobs with given job_name_prefix.

Parameters:

Yields:

A sagemaker.remote_function.client.Future instance.

client.get_future(sagemaker_session=None)

Get a future object with information about a job with the given job_name.

Parameters:

Returns:

A sagemaker.remote_function.client.Future instance.

Return type:

Future

CustomFileFilter

class sagemaker.remote_function.custom_file_filter.CustomFileFilter(*, ignore_name_patterns=None)

Configuration that specifies how the local working directory should be packaged.

Initialize a CustomFileFilter.

Parameters:

ignore_name_patterns (List _[_str]) – ignore files or directories with names that match one of the glob-style patterns. Defaults to None.