sagemaker.core.transformer#

Placeholder docstring

Functions

logs_for_transform_job(sagemaker_session, ...)

Display logs for a given training job, optionally tailing them until job is complete.

Classes

Transformer(model_name, instance_count, ...)

A class for handling creating and interacting with Amazon SageMaker transform jobs.

class sagemaker.core.transformer.Transformer(model_name: str | PipelineVariable, instance_count: int | PipelineVariable, instance_type: str | PipelineVariable, strategy: str | PipelineVariable | None = None, assemble_with: str | PipelineVariable | None = None, output_path: str | PipelineVariable | None = None, output_kms_key: str | PipelineVariable | None = None, accept: str | PipelineVariable | None = None, max_concurrent_transforms: int | PipelineVariable | None = None, max_payload: int | PipelineVariable | None = None, tags: List[Dict[str, str | PipelineVariable]] | Dict[str, str | PipelineVariable] | None = None, env: Dict[str, str | PipelineVariable] | None = None, base_transform_job_name: str | None = None, sagemaker_session: Session | None = None, volume_kms_key: str | PipelineVariable | None = None, transform_ami_version: str | PipelineVariable | None = None)[source]#

Bases: object

A class for handling creating and interacting with Amazon SageMaker transform jobs.

JOB_CLASS_NAME = 'transform-job'#
classmethod attach(transform_job_name, sagemaker_session=None)[source]#

Attach an existing transform job to a new Transformer instance

Parameters:
  • transform_job_name (str) – Name for the transform job to be attached.

  • sagemaker_session (sagemaker.core.helper.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one will be created using the default AWS configuration chain.

Returns:

The Transformer instance with the specified transform job attached.

Return type:

sagemaker.transformer.Transformer

delete_model()[source]#

Delete the corresponding SageMaker model for this Transformer.

stop_transform_job(wait=True)[source]#

Stop latest running batch transform job.

transform(data: str | PipelineVariable, data_type: str | PipelineVariable = 'S3Prefix', content_type: str | PipelineVariable | None = None, compression_type: str | PipelineVariable | None = None, split_type: str | PipelineVariable | None = None, job_name: str | None = None, input_filter: str | PipelineVariable | None = None, output_filter: str | PipelineVariable | None = None, join_source: str | PipelineVariable | None = None, experiment_config: Dict[str, str] | None = None, model_client_config: Dict[str, str | PipelineVariable] | None = None, batch_data_capture_config: BatchDataCaptureConfig = None, wait: bool = True, logs: bool = True)[source]#

Start a new transform job.

Parameters:
  • data (str or PipelineVariable) – Input data location in S3.

  • data_type (str or PipelineVariable) –

    What the S3 location defines (default: ‘S3Prefix’). Valid values:

    • ’S3Prefix’ - the S3 URI defines a key name prefix. All objects with this prefix

      will be used as inputs for the transform job.

    • ’ManifestFile’ - the S3 URI points to a single manifest file listing each S3

      object to use as an input for the transform job.

  • content_type (str or PipelineVariable) – MIME type of the input data (default: None).

  • compression_type (str or PipelineVariable) – Compression type of the input data, if compressed (default: None). Valid values: ‘Gzip’, None.

  • split_type (str or PipelineVariable) – The record delimiter for the input object (default: ‘None’). Valid values: ‘None’, ‘Line’, ‘RecordIO’, and ‘TFRecord’.

  • job_name (str) – job name (default: None). If not specified, one will be generated.

  • input_filter (str or PipelineVariable) – A JSONPath to select a portion of the input to pass to the algorithm container for inference. If you omit the field, it gets the value ‘$’, representing the entire input. For CSV data, each row is taken as a JSON array, so only index-based JSONPaths can be applied, e.g. $[0], $[1:]. CSV data should follow the RFC format. See Supported JSONPath Operators for a table of supported JSONPath operators. For more information, see the SageMaker API documentation for CreateTransformJob. Some examples: “$[1:]”, “$.features” (default: None).

  • output_filter (str or PipelineVariable) –

    A JSONPath to select a portion of the joined/original output to return as the output. For more information, see the SageMaker API documentation for CreateTransformJob. Some examples: “$[1:]”, “$.prediction” (default: None).

  • join_source (str or PipelineVariable) – The source of data to be joined to the transform output. It can be set to ‘Input’ meaning the entire input record will be joined to the inference result. You can use OutputFilter to select the useful portion before uploading to S3. (default: None). Valid values: Input, None.

  • experiment_config (dict[str, str]) – Experiment management configuration. Optionally, the dict can contain three keys: ‘ExperimentName’, ‘TrialName’, and ‘TrialComponentDisplayName’. The behavior of setting these keys is as follows: * If ExperimentName is supplied but TrialName is not a Trial will be automatically created and the job’s Trial Component associated with the Trial. * If TrialName is supplied and the Trial already exists the job’s Trial Component will be associated with the Trial. * If both ExperimentName and TrialName are not supplied the trial component will be unassociated. * TrialComponentDisplayName is used for display in Studio. * Both ExperimentName and TrialName will be ignored if the Transformer instance is built with PipelineSession. However, the value of TrialComponentDisplayName is honored for display in Studio.

  • model_client_config (dict[str, str] or dict[str, PipelineVariable]) – Model configuration. Dictionary contains two optional keys, ‘InvocationsTimeoutInSeconds’, and ‘InvocationsMaxRetries’. (default: None).

  • batch_data_capture_config (BatchDataCaptureConfig) – Configuration object which specifies the configurations related to the batch data capture for the transform job (default: None).

  • batch_data_capture_config – Configuration object which specifies the configurations related to the batch data capture for the transform job (default: None).

  • wait (bool) – Whether the call should wait until the job completes (default: True).

  • logs (bool) – Whether to show the logs produced by the job. Only meaningful when wait is True (default: True).

Returns:

None or pipeline step arguments in case the Transformer instance is built with PipelineSession

wait(logs=True)[source]#

Placeholder docstring

sagemaker.core.transformer.logs_for_transform_job(sagemaker_session, job_name, wait=False, poll=10)[source]#

Display logs for a given training job, optionally tailing them until job is complete.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

Parameters:
  • job_name (str) – Name of the transform job to display the logs for.

  • wait (bool) – Whether to keep looking for new log entries until the job completes (default: False).

  • poll (int) – The interval in seconds between polling for new log entries and job completion (default: 5).

Raises:

ValueError – If the transform job fails.