Transformer(model_name, instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, max_concurrent_transforms=None, max_payload=None, tags=None, env=None, base_transform_job_name=None, sagemaker_session=None, volume_kms_key=None)¶
A class for handling creating and interacting with Amazon SageMaker transform jobs.
base_transform_job_name (str) – Prefix for the transform job when the
transform()method launches. If not specified, a default prefix will be generated based on the training image name that was used to train the model associated with the transform job.
sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.
transform(data, data_type='S3Prefix', content_type=None, compression_type=None, split_type=None, job_name=None, input_filter=None, output_filter=None, join_source=None, experiment_config=None, model_client_config=None, wait=True, logs=True)¶
Start a new transform job.
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.
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. $, $[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).
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:
wait (bool) – Whether the call should wait until the job completes (default:
logs (bool) – Whether to show the logs produced by the job. Only meaningful when wait is
None or pipeline step arguments in case the Transformer instance is built with
Delete the corresponding SageMaker model for this Transformer.
Stop latest running batch transform job.
Attach an existing transform job to a new Transformer instance
transform_job_name (str) – Name for the transform job to be attached.
sagemaker_session (sagemaker.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.
The Transformer instance with the specified transform job attached.
- Return type