sagemaker.core.modules.configs

Contents

sagemaker.core.modules.configs#

This module provides the configuration classes used in sagemaker.modules.

Some of these classes are re-exported from sagemaker_core.shapes. For convinence, users can import these classes directly from sagemaker.modules.configs.

For more documentation on sagemaker_core.shapes, see:

Classes

BaseConfig()

Compute(*[, instance_type, instance_count, ...])

Compute.

InputData(*[, channel_name, data_source])

InputData.

Networking(*, security_group_ids, subnets[, ...])

Networking.

SourceCode(*[, source_dir, requirements, ...])

SourceCode.

class sagemaker.core.modules.configs.Channel(*, channel_name: str | PipelineVariable, data_source: DataSource, content_type: str | PipelineVariable | None = Unassigned(), compression_type: str | PipelineVariable | None = Unassigned(), record_wrapper_type: str | PipelineVariable | None = Unassigned(), input_mode: str | PipelineVariable | None = Unassigned(), shuffle_config: ShuffleConfig | None = Unassigned(), enable_ffm: bool | None = Unassigned())[source]#

Bases: Base

A channel is a named input source that training algorithms can consume.

channel_name#
Type:

The name of the channel.

data_source#
Type:

The location of the channel data.

content_type#
Type:

The MIME type of the data.

compression_type#
Type:

If training data is compressed, the compression type. The default value is None. CompressionType is used only in Pipe input mode. In File mode, leave this field unset or set it to None.

record_wrapper_type#
Type:

Specify RecordIO as the value when input data is in raw format but the training algorithm requires the RecordIO format. In this case, SageMaker wraps each individual S3 object in a RecordIO record. If the input data is already in RecordIO format, you don’t need to set this attribute. For more information, see Create a Dataset Using RecordIO. In File mode, leave this field unset or set it to None.

input_mode#
Type:

(Optional) The input mode to use for the data channel in a training job. If you don’t set a value for InputMode, SageMaker uses the value set for TrainingInputMode. Use this parameter to override the TrainingInputMode setting in a AlgorithmSpecification request when you have a channel that needs a different input mode from the training job’s general setting. To download the data from Amazon Simple Storage Service (Amazon S3) to the provisioned ML storage volume, and mount the directory to a Docker volume, use File input mode. To stream data directly from Amazon S3 to the container, choose Pipe input mode. To use a model for incremental training, choose File input model.

shuffle_config#
Type:

A configuration for a shuffle option for input data in a channel. If you use S3Prefix for S3DataType, this shuffles the results of the S3 key prefix matches. If you use ManifestFile, the order of the S3 object references in the ManifestFile is shuffled. If you use AugmentedManifestFile, the order of the JSON lines in the AugmentedManifestFile is shuffled. The shuffling order is determined using the Seed value. For Pipe input mode, shuffling is done at the start of every epoch. With large datasets this ensures that the order of the training data is different for each epoch, it helps reduce bias and possible overfitting. In a multi-node training job when ShuffleConfig is combined with S3DataDistributionType of ShardedByS3Key, the data is shuffled across nodes so that the content sent to a particular node on the first epoch might be sent to a different node on the second epoch.

enable_ffm#
Type:

bool | None

channel_name: str | PipelineVariable#
compression_type: str | PipelineVariable | None#
content_type: str | PipelineVariable | None#
data_source: DataSource#
enable_ffm: bool | None#
input_mode: str | PipelineVariable | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

record_wrapper_type: str | PipelineVariable | None#
shuffle_config: ShuffleConfig | None#
class sagemaker.core.modules.configs.CheckpointConfig(*, s3_uri: str | PipelineVariable, local_path: str | PipelineVariable | None = Unassigned())[source]#

Bases: Base

Contains information about the output location for managed spot training checkpoint data.

s3_uri#
Type:

Identifies the S3 path where you want SageMaker to store checkpoints. For example, s3://bucket-name/key-name-prefix.

local_path#
Type:

(Optional) The local directory where checkpoints are written. The default directory is /opt/ml/checkpoints/.

local_path: str | PipelineVariable | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

s3_uri: str | PipelineVariable#
class sagemaker.core.modules.configs.Compute(*, instance_type: str | PipelineVariable | None = Unassigned(), instance_count: int | PipelineVariable | None = Unassigned(), volume_size_in_gb: int | None = 30, volume_kms_key_id: str | PipelineVariable | None = Unassigned(), keep_alive_period_in_seconds: int | PipelineVariable | None = Unassigned(), capacity_reservation_ids: List[str | PipelineVariable] | None = Unassigned(), instance_groups: List[InstanceGroup] | None = Unassigned(), capacity_schedules_config: CapacitySchedulesConfig | None = Unassigned(), training_plan_arn: str | PipelineVariable | None = Unassigned(), instance_placement_config: InstancePlacementConfig | None = Unassigned(), enable_managed_spot_training: bool | None = None)[source]#

Bases: ResourceConfig

Compute.

The Compute class is a subclass of sagemaker_core.shapes.ResourceConfig and allows the user to specify the compute resources for the training job.

Parameters:
  • instance_type (Optional[str]) – The ML compute instance type. For information about available instance types, see https://aws.amazon.com/sagemaker/pricing/.

  • instance_count (Optional[int]) – The number of ML compute instances to use. For distributed training, provide a value greater than 1.

  • volume_size_in_gb (Optional[int]) – The size of the ML storage volume that you want to provision. ML storage volumes store model artifacts and incremental states. Training algorithms might also use the ML storage volume for scratch space. Default: 30

  • volume_kms_key_id (Optional[str]) – The Amazon Web Services KMS key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance(s) that run the training job.

  • keep_alive_period_in_seconds (Optional[int]) – The duration of time in seconds to retain configured resources in a warm pool for subsequent training jobs.

  • instance_groups (Optional[List[InstanceGroup]]) – A list of instance groups for heterogeneous clusters to be used in the training job.

  • enable_managed_spot_training (Optional[bool]) – To train models using managed spot training, choose True. Managed spot training provides a fully managed and scalable infrastructure for training machine learning models. this option is useful when training jobs can be interrupted and when there is flexibility when the training job is run.

enable_managed_spot_training: bool | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

volume_size_in_gb: int | None#
class sagemaker.core.modules.configs.DataSource(*, s3_data_source: S3DataSource | None = Unassigned(), file_system_data_source: FileSystemDataSource | None = Unassigned(), dataset_source: DatasetSource | None = Unassigned())[source]#

Bases: Base

Describes the location of the channel data.

s3_data_source#
Type:

The S3 location of the data source that is associated with a channel.

file_system_data_source#
Type:

The file system that is associated with a channel.

dataset_source#
Type:

sagemaker.core.shapes.shapes.DatasetSource | None

dataset_source: DatasetSource | None#
file_system_data_source: FileSystemDataSource | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

s3_data_source: S3DataSource | None#
class sagemaker.core.modules.configs.FileSystemDataSource(*, file_system_id: str | PipelineVariable, file_system_access_mode: str | PipelineVariable, file_system_type: str | PipelineVariable, directory_path: str | PipelineVariable)[source]#

Bases: Base

Specifies a file system data source for a channel.

file_system_id#
Type:

The file system id.

file_system_access_mode#
Type:

The access mode of the mount of the directory associated with the channel. A directory can be mounted either in ro (read-only) or rw (read-write) mode.

file_system_type#
Type:

The file system type.

directory_path#
Type:

The full path to the directory to associate with the channel.

directory_path: str | PipelineVariable#
file_system_access_mode: str | PipelineVariable#
file_system_id: str | PipelineVariable#
file_system_type: str | PipelineVariable#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.InfraCheckConfig(*, enable_infra_check: bool | None = Unassigned())[source]#

Bases: Base

Configuration information for the infrastructure health check of a training job. A SageMaker-provided health check tests the health of instance hardware and cluster network connectivity.

enable_infra_check#
Type:

Enables an infrastructure health check.

enable_infra_check: bool | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.InputData(*, channel_name: str = None, data_source: str | FileSystemDataSource | S3DataSource = None)[source]#

Bases: BaseConfig

InputData.

This config allows the user to specify an input data source for the training job.

Will be found at /opt/ml/input/data/<channel_name> within the training container. For convience, can be referenced inside the training container like:

import os
input_data_dir = os.environ['SM_CHANNEL_<channel_name>']
Parameters:
  • channel_name (str) – The name of the input data source channel.

  • data_source (Union[str, S3DataSource, FileSystemDataSource]) – The data source for the channel. Can be an S3 URI string, local file path string, S3DataSource object, or FileSystemDataSource object.

channel_name: str#
data_source: str | FileSystemDataSource | S3DataSource#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.InstanceGroup(*, instance_type: str | PipelineVariable, instance_count: int, instance_group_name: str | PipelineVariable)[source]#

Bases: Base

Defines an instance group for heterogeneous cluster training. When requesting a training job using the CreateTrainingJob API, you can configure multiple instance groups .

instance_type#
Type:

Specifies the instance type of the instance group.

instance_count#
Type:

Specifies the number of instances of the instance group.

instance_group_name#
Type:

Specifies the name of the instance group.

instance_count: int#
instance_group_name: str | PipelineVariable#
instance_type: str | PipelineVariable#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.MetricDefinition(*, name: str | PipelineVariable, regex: str | PipelineVariable)[source]#

Bases: Base

Specifies a metric that the training algorithm writes to stderr or stdout. You can view these logs to understand how your training job performs and check for any errors encountered during training. SageMaker hyperparameter tuning captures all defined metrics. Specify one of the defined metrics to use as an objective metric using the TuningObjective parameter in the HyperParameterTrainingJobDefinition API to evaluate job performance during hyperparameter tuning.

name#
Type:

The name of the metric.

regex#
Type:

A regular expression that searches the output of a training job and gets the value of the metric. For more information about using regular expressions to define metrics, see Defining metrics and environment variables.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str | PipelineVariable#
regex: str | PipelineVariable#
class sagemaker.core.modules.configs.Networking(*, security_group_ids: List[str | PipelineVariable], subnets: List[str | PipelineVariable], enable_network_isolation: bool | None = None, enable_inter_container_traffic_encryption: bool | None = None)[source]#

Bases: VpcConfig

Networking.

The Networking class is a subclass of sagemaker_core.shapes.VpcConfig and allows the user to specify the networking configuration for the training job.

Parameters:
  • security_group_ids (Optional[List[str]]) – The VPC security group IDs, in the form sg-xxxxxxxx. Specify the security groups for the VPC that is specified in the Subnets field.

  • subnets (Optional[List[str]]) – The ID of the subnets in the VPC to which you want to connect your training job or model.

  • enable_network_isolation (Optional[bool]) – Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If you enable network isolation for training jobs that are configured to use a VPC, SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.

  • enable_inter_container_traffic_encryption (Optional[bool]) – To encrypt all communications between ML compute instances in distributed training choose True. Encryption provides greater security for distributed training, but training might take longer. How long it takes depends on the amount of communication between compute instances, especially if you use a deep learning algorithm in distributed training.

enable_inter_container_traffic_encryption: bool | None#
enable_network_isolation: bool | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.OutputDataConfig(*, s3_output_path: str | PipelineVariable, kms_key_id: str | PipelineVariable | None = Unassigned(), compression_type: str | PipelineVariable | None = Unassigned(), remove_job_name_from_s3_output_path: bool | None = Unassigned(), disable_model_upload: bool | None = Unassigned(), channels: List[OutputChannel] | None = Unassigned())[source]#

Bases: Base

Provides information about how to store model training results (model artifacts).

kms_key_id#
Type:

The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side encryption. The KmsKeyId can be any of the following formats: // KMS Key ID “1234abcd-12ab-34cd-56ef-1234567890ab” // Amazon Resource Name (ARN) of a KMS Key “arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab” // KMS Key Alias “alias/ExampleAlias” // Amazon Resource Name (ARN) of a KMS Key Alias “arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias” If you use a KMS key ID or an alias of your KMS key, the SageMaker execution role must include permissions to call kms:Encrypt. If you don’t provide a KMS key ID, SageMaker uses the default KMS key for Amazon S3 for your role’s account. For more information, see KMS-Managed Encryption Keys in the Amazon Simple Storage Service Developer Guide. If the output data is stored in Amazon S3 Express One Zone, it is encrypted with server-side encryption with Amazon S3 managed keys (SSE-S3). KMS key is not supported for Amazon S3 Express One Zone The KMS key policy must grant permission to the IAM role that you specify in your CreateTrainingJob, CreateTransformJob, or CreateHyperParameterTuningJob requests. For more information, see Using Key Policies in Amazon Web Services KMS in the Amazon Web Services Key Management Service Developer Guide.

s3_output_path#
Type:

Identifies the S3 path where you want SageMaker to store the model artifacts. For example, s3://bucket-name/key-name-prefix.

compression_type#
Type:

The model output compression type. Select None to output an uncompressed model, recommended for large model outputs. Defaults to gzip.

remove_job_name_from_s3_output_path#
Type:

bool | None

disable_model_upload#
Type:

bool | None

channels#
Type:

List[sagemaker.core.shapes.shapes.OutputChannel] | None

channels: List[OutputChannel] | None#
compression_type: str | PipelineVariable | None#
disable_model_upload: bool | None#
kms_key_id: str | PipelineVariable | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

remove_job_name_from_s3_output_path: bool | None#
s3_output_path: str | PipelineVariable#
class sagemaker.core.modules.configs.RemoteDebugConfig(*, enable_remote_debug: bool | None = Unassigned())[source]#

Bases: Base

Configuration for remote debugging for the CreateTrainingJob API. To learn more about the remote debugging functionality of SageMaker, see Access a training container through Amazon Web Services Systems Manager (SSM) for remote debugging.

enable_remote_debug#
Type:

If set to True, enables remote debugging.

enable_remote_debug: bool | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.RetryStrategy(*, maximum_retry_attempts: int)[source]#

Bases: Base

The retry strategy to use when a training job fails due to an InternalServerError. RetryStrategy is specified as part of the CreateTrainingJob and CreateHyperParameterTuningJob requests. You can add the StoppingCondition parameter to the request to limit the training time for the complete job.

maximum_retry_attempts#
Type:

The number of times to retry the job. When the job is retried, it’s SecondaryStatus is changed to STARTING.

maximum_retry_attempts: int#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.S3DataSource(*, s3_data_type: str | PipelineVariable, s3_uri: str | PipelineVariable, s3_data_distribution_type: str | PipelineVariable | None = Unassigned(), attribute_names: List[str | PipelineVariable] | None = Unassigned(), instance_group_names: List[str | PipelineVariable] | None = Unassigned(), model_access_config: ModelAccessConfig | None = Unassigned(), hub_access_config: HubAccessConfig | None = Unassigned())[source]#

Bases: Base

Describes the S3 data source. Your input bucket must be in the same Amazon Web Services region as your training job.

s3_data_type#
Type:

If you choose S3Prefix, S3Uri identifies a key name prefix. SageMaker uses all objects that match the specified key name prefix for model training. If you choose ManifestFile, S3Uri identifies an object that is a manifest file containing a list of object keys that you want SageMaker to use for model training. If you choose AugmentedManifestFile, S3Uri identifies an object that is an augmented manifest file in JSON lines format. This file contains the data you want to use for model training. AugmentedManifestFile can only be used if the Channel’s input mode is Pipe. If you choose Converse, S3Uri identifies an Amazon S3 location that contains data formatted according to Converse format. This format structures conversational messages with specific roles and content types used for training and fine-tuning foundational models.

s3_uri#
Type:

Depending on the value specified for the S3DataType, identifies either a key name prefix or a manifest. For example: A key name prefix might look like this: s3://bucketname/exampleprefix/ A manifest might look like this: s3://bucketname/example.manifest A manifest is an S3 object which is a JSON file consisting of an array of elements. The first element is a prefix which is followed by one or more suffixes. SageMaker appends the suffix elements to the prefix to get a full set of S3Uri. Note that the prefix must be a valid non-empty S3Uri that precludes users from specifying a manifest whose individual S3Uri is sourced from different S3 buckets. The following code example shows a valid manifest format: [ {“prefix”: “s3://customer_bucket/some/prefix/”}, “relative/path/to/custdata-1”, “relative/path/custdata-2”, … “relative/path/custdata-N” ] This JSON is equivalent to the following S3Uri list: s3://customer_bucket/some/prefix/relative/path/to/custdata-1 s3://customer_bucket/some/prefix/relative/path/custdata-2 … s3://customer_bucket/some/prefix/relative/path/custdata-N The complete set of S3Uri in this manifest is the input data for the channel for this data source. The object that each S3Uri points to must be readable by the IAM role that SageMaker uses to perform tasks on your behalf. Your input bucket must be located in same Amazon Web Services region as your training job.

s3_data_distribution_type#
Type:

If you want SageMaker to replicate the entire dataset on each ML compute instance that is launched for model training, specify FullyReplicated. If you want SageMaker to replicate a subset of data on each ML compute instance that is launched for model training, specify ShardedByS3Key. If there are n ML compute instances launched for a training job, each instance gets approximately 1/n of the number of S3 objects. In this case, model training on each machine uses only the subset of training data. Don’t choose more ML compute instances for training than available S3 objects. If you do, some nodes won’t get any data and you will pay for nodes that aren’t getting any training data. This applies in both File and Pipe modes. Keep this in mind when developing algorithms. In distributed training, where you use multiple ML compute EC2 instances, you might choose ShardedByS3Key. If the algorithm requires copying training data to the ML storage volume (when TrainingInputMode is set to File), this copies 1/n of the number of objects.

attribute_names#
Type:

A list of one or more attribute names to use that are found in a specified augmented manifest file.

instance_group_names#
Type:

A list of names of instance groups that get data from the S3 data source.

model_access_config#
Type:

sagemaker.core.shapes.shapes.ModelAccessConfig | None

hub_access_config#
Type:

The configuration for a private hub model reference that points to a SageMaker JumpStart public hub model.

attribute_names: List[str | PipelineVariable] | None#
hub_access_config: HubAccessConfig | None#
instance_group_names: List[str | PipelineVariable] | None#
model_access_config: ModelAccessConfig | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

s3_data_distribution_type: str | PipelineVariable | None#
s3_data_type: str | PipelineVariable#
s3_uri: str | PipelineVariable#
class sagemaker.core.modules.configs.SessionChainingConfig(*, enable_session_tag_chaining: bool | None = Unassigned())[source]#

Bases: Base

Contains information about attribute-based access control (ABAC) for a training job. The session chaining configuration uses Amazon Security Token Service (STS) for your training job to request temporary, limited-privilege credentials to tenants. For more information, see Attribute-based access control (ABAC) for multi-tenancy training.

enable_session_tag_chaining#
Type:

Set to True to allow SageMaker to extract session tags from a training job creation role and reuse these tags when assuming the training job execution role.

enable_session_tag_chaining: bool | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.ShuffleConfig(*, seed: int)[source]#

Bases: Base

A configuration for a shuffle option for input data in a channel. If you use S3Prefix for S3DataType, the results of the S3 key prefix matches are shuffled. If you use ManifestFile, the order of the S3 object references in the ManifestFile is shuffled. If you use AugmentedManifestFile, the order of the JSON lines in the AugmentedManifestFile is shuffled. The shuffling order is determined using the Seed value. For Pipe input mode, when ShuffleConfig is specified shuffling is done at the start of every epoch. With large datasets, this ensures that the order of the training data is different for each epoch, and it helps reduce bias and possible overfitting. In a multi-node training job when ShuffleConfig is combined with S3DataDistributionType of ShardedByS3Key, the data is shuffled across nodes so that the content sent to a particular node on the first epoch might be sent to a different node on the second epoch.

seed#
Type:

Determines the shuffling order in ShuffleConfig value.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

seed: int#
class sagemaker.core.modules.configs.SourceCode(*, source_dir: str | None = None, requirements: str | None = None, entry_script: str | None = None, command: str | None = None, ignore_patterns: List[str] | None = ['.env', '.git', '__pycache__', '.DS_Store', '.cache', '.ipynb_checkpoints'])[source]#

Bases: BaseConfig

SourceCode.

The SourceCode class allows the user to specify the source code location, dependencies, entry script, or commands to be executed in the training job container.

Parameters:
  • source_dir (Optional[str]) – The local directory containing the source code to be used in the training job container.

  • requirements (Optional[str]) – The path within source_dir to a requirements.txt file. If specified, the listed requirements will be installed in the training job container.

  • entry_script (Optional[str]) – The path within source_dir to the entry script that will be executed in the training job container. If not specified, command must be provided.

  • command (Optional[str]) – The command(s) to execute in the training job container. Example: “python my_script.py”. If not specified, entry_script must be provided.

  • ignore_patterns – (Optional[List[str]]) : The ignore patterns to ignore specific files/folders when uploading to S3. If not specified, default to: [‘.env’, ‘.git’, ‘__pycache__’, ‘.DS_Store’, ‘.cache’, ‘.ipynb_checkpoints’].

command: str | None#
entry_script: str | None#
ignore_patterns: List[str] | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

requirements: str | None#
source_dir: str | None#
class sagemaker.core.modules.configs.StoppingCondition(*, max_runtime_in_seconds: int | None = Unassigned(), max_wait_time_in_seconds: int | None = Unassigned(), max_pending_time_in_seconds: int | None = Unassigned())[source]#

Bases: Base

Specifies a limit to how long a job can run. When the job reaches the time limit, SageMaker ends the job. Use this API to cap costs. To stop a training job, SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. The training algorithms provided by SageMaker automatically save the intermediate results of a model training job when possible. This attempt to save artifacts is only a best effort case as model might not be in a state from which it can be saved. For example, if training has just started, the model might not be ready to save. When saved, this intermediate data is a valid model artifact. You can use it to create a model with CreateModel. The Neural Topic Model (NTM) currently does not support saving intermediate model artifacts. When training NTMs, make sure that the maximum runtime is sufficient for the training job to complete.

max_runtime_in_seconds#
Type:

The maximum length of time, in seconds, that a training or compilation job can run before it is stopped. For compilation jobs, if the job does not complete during this time, a TimeOut error is generated. We recommend starting with 900 seconds and increasing as necessary based on your model. For all other jobs, if the job does not complete during this time, SageMaker ends the job. When RetryStrategy is specified in the job request, MaxRuntimeInSeconds specifies the maximum time for all of the attempts in total, not each individual attempt. The default value is 1 day. The maximum value is 28 days. The maximum time that a TrainingJob can run in total, including any time spent publishing metrics or archiving and uploading models after it has been stopped, is 30 days.

max_wait_time_in_seconds#
Type:

The maximum length of time, in seconds, that a managed Spot training job has to complete. It is the amount of time spent waiting for Spot capacity plus the amount of time the job can run. It must be equal to or greater than MaxRuntimeInSeconds. If the job does not complete during this time, SageMaker ends the job. When RetryStrategy is specified in the job request, MaxWaitTimeInSeconds specifies the maximum time for all of the attempts in total, not each individual attempt.

max_pending_time_in_seconds#
Type:

The maximum length of time, in seconds, that a training or compilation job can be pending before it is stopped. When working with training jobs that use capacity from training plans, not all Pending job states count against the MaxPendingTimeInSeconds limit. The following scenarios do not increment the MaxPendingTimeInSeconds counter: The plan is in a Scheduled state: Jobs queued (in Pending status) before a plan’s start date (waiting for scheduled start time) Between capacity reservations: Jobs temporarily back to Pending status between two capacity reservation periods MaxPendingTimeInSeconds only increments when jobs are actively waiting for capacity in an Active plan.

max_pending_time_in_seconds: int | None#
max_runtime_in_seconds: int | None#
max_wait_time_in_seconds: int | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class sagemaker.core.modules.configs.Tag(*, key: str | PipelineVariable, value: str | PipelineVariable)[source]#

Bases: Base

A tag object that consists of a key and an optional value, used to manage metadata for SageMaker Amazon Web Services resources. You can add tags to notebook instances, training jobs, hyperparameter tuning jobs, batch transform jobs, models, labeling jobs, work teams, endpoint configurations, and endpoints. For more information on adding tags to SageMaker resources, see AddTags. For more information on adding metadata to your Amazon Web Services resources with tagging, see Tagging Amazon Web Services resources. For advice on best practices for managing Amazon Web Services resources with tagging, see Tagging Best Practices: Implement an Effective Amazon Web Services Resource Tagging Strategy.

key#
Type:

The tag key. Tag keys must be unique per resource.

value#
Type:

The tag value.

key: str | PipelineVariable#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

value: str | PipelineVariable#
class sagemaker.core.modules.configs.TensorBoardOutputConfig(*, s3_output_path: str | PipelineVariable, local_path: str | PipelineVariable | None = Unassigned())[source]#

Bases: Base

Configuration of storage locations for the Amazon SageMaker Debugger TensorBoard output data.

local_path#
Type:

Path to local storage location for tensorBoard output. Defaults to /opt/ml/output/tensorboard.

s3_output_path#
Type:

Path to Amazon S3 storage location for TensorBoard output.

local_path: str | PipelineVariable | None#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

s3_output_path: str | PipelineVariable#
class sagemaker.core.modules.configs.TrainingImageConfig(*, training_repository_access_mode: str | PipelineVariable, training_repository_auth_config: TrainingRepositoryAuthConfig | None = Unassigned())[source]#

Bases: Base

The configuration to use an image from a private Docker registry for a training job.

training_repository_access_mode#
Type:

The method that your training job will use to gain access to the images in your private Docker registry. For access to an image in a private Docker registry, set to Vpc.

training_repository_auth_config#
Type:

An object containing authentication information for a private Docker registry containing your training images.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

training_repository_access_mode: str | PipelineVariable#
training_repository_auth_config: TrainingRepositoryAuthConfig | None#
class sagemaker.core.modules.configs.TrainingRepositoryAuthConfig(*, training_repository_credentials_provider_arn: str | PipelineVariable)[source]#

Bases: Base

An object containing authentication information for a private Docker registry.

training_repository_credentials_provider_arn#
Type:

The Amazon Resource Name (ARN) of an Amazon Web Services Lambda function used to give SageMaker access credentials to your private Docker registry.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'protected_namespaces': (), 'validate_assignment': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

training_repository_credentials_provider_arn: str | PipelineVariable#