sagemaker.core.remote_function.runtime_environment.runtime_environment_manager#

SageMaker runtime environment module. This must be kept independent of SageMaker PySDK

Functions

get_logger()

Return a logger with the name 'sagemaker'

Classes

RuntimeEnvironmentManager()

Runtime Environment Manager class to manage runtime environment.

Exceptions

RuntimeEnvironmentError(message)

The base exception class for bootstrap env excepitons

exception sagemaker.core.remote_function.runtime_environment.runtime_environment_manager.RuntimeEnvironmentError(message)[source]#

Bases: Exception

The base exception class for bootstrap env excepitons

class sagemaker.core.remote_function.runtime_environment.runtime_environment_manager.RuntimeEnvironmentManager[source]#

Bases: object

Runtime Environment Manager class to manage runtime environment.

bootstrap(local_dependencies_file: str, client_python_version: str, conda_env: str | None = None)[source]#

Bootstraps the runtime environment by installing the additional dependencies if any.

Parameters:
  • local_dependencies_file (str) – path where dependencies file exists.

  • conda_env (str) – conda environment to be activated. Default is None.

Returns: None

change_dir_permission(dirs: list, new_permission: str)[source]#

Change the permission of given directories

Parameters:
  • dirs (list[str]) – A list of directories for permission update.

  • new_permission (str) – The new permission for the given directories.

run_pre_exec_script(pre_exec_script_path: str)[source]#

Runs script of pre-execution commands if existing.

Parameters:

pre_exec_script_path (str) – Path to pre-execution command script file.

snapshot(dependencies: str | None = None) str[source]#

Creates snapshot of the user’s environment

If a req.txt or conda.yml file is provided, it verifies their existence and returns the local file path If auto_capture is set, this method will take the snapshot of user’s dependencies installed in the local runtime. Current support for auto_capture: * conda env, generate a yml file and return it’s local path

Parameters:

dependencies (str) – Local path where dependencies file exists.

Returns:

file path of the existing or generated dependencies file

sagemaker.core.remote_function.runtime_environment.runtime_environment_manager.get_logger()[source]#

Return a logger with the name ‘sagemaker’