Transformer: Transformer class

TransformerR Documentation

Transformer class

Description

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

Methods

Public methods


Method new()

Initialize a “Transformer“.

Usage
Transformer$new(
  model_name,
  instance_count,
  instance_type,
  strategy = NULL,
  assemble_with = NULL,
  output_path = NULL,
  output_kms_key = NULL,
  accept = NULL,
  max_concurrent_transforms = NULL,
  max_payload = NULL,
  tags = NULL,
  env = NULL,
  base_transform_job_name = NULL,
  sagemaker_session = NULL,
  volume_kms_key = NULL
)
Arguments
model_name

(str): Name of the SageMaker model being used for the transform job.

instance_count

(int): Number of EC2 instances to use.

instance_type

(str): Type of EC2 instance to use, for example, 'ml.c4.xlarge'.

strategy

(str): The strategy used to decide how to batch records in a single request (default: None). Valid values: 'MultiRecord' and 'SingleRecord'.

assemble_with

(str): How the output is assembled (default: None). Valid values: 'Line' or 'None'.

output_path

(str): S3 location for saving the transform result. If not specified, results are stored to a default bucket.

output_kms_key

(str): Optional. KMS key ID for encrypting the transform output (default: None).

accept

(str): The accept header passed by the client to the inference endpoint. If it is supported by the endpoint, it will be the format of the batch transform output.

max_concurrent_transforms

(int): The maximum number of HTTP requests to be made to each individual transform container at one time.

max_payload

(int): Maximum size of the payload in a single HTTP request to the container in MB.

tags

(list[dict]): List of tags for labeling a transform job (default: None). For more, see the SageMaker API documentation for 'Tag <https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html>'_.

env

(dict): Environment variables to be set for use during the transform job (default: None).

base_transform_job_name

(str): Prefix for the transform job when the :meth:'~sagemaker.transformer.Transformer.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.

volume_kms_key

(str): Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).


Method transform()

Start a new transform job.

Usage
Transformer$transform(
  data,
  data_type = "S3Prefix",
  content_type = NULL,
  compression_type = NULL,
  split_type = NULL,
  job_name = NULL,
  input_filter = NULL,
  output_filter = NULL,
  join_source = NULL,
  experiment_config = NULL,
  model_client_config = NULL,
  wait = TRUE,
  logs = TRUE,
  ...
)
Arguments
data

(str): Input data location in S3.

data_type

(str): 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): MIME type of the input data (default: None).

compression_type

(str): Compression type of the input data, if compressed (default: None). Valid values: 'Gzip', None.

split_type

(str): 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): 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 <https://tools.ietf.org/html/rfc4180>'_. See 'Supported JSONPath Operators <https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform-data-processing.html#data-processing-operators>'_ for a table of supported JSONPath operators. For more information, see the SageMaker API documentation for 'CreateTransformJob <https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html>'_. Some examples: "$[1:]", "$.features" (default: None).

output_filter

(str): 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 <https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateTransformJob.html>'_. Some examples: "$[1:]", "$.prediction" (default: None).

join_source

(str): 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. Dictionary contains three optional keys, 'ExperimentName', 'TrialName', and 'TrialComponentDisplayName'. (default: “None“).

model_client_config

(dict[str, str]): Model configuration. Dictionary contains two optional keys, 'InvocationsTimeoutInSeconds', and 'InvocationsMaxRetries'. (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).

...

Other parameters (currently not used)

Returns

NULL invisible


Method delete_model()

Delete the corresponding SageMaker model for this Transformer.

Usage
Transformer$delete_model()

Method wait()

Wait for latest running batch transform job

Usage
Transformer$wait(logs = TRUE)
Arguments
logs

return logs


Method stop_transform_job()

Stop latest running batch transform job.

Usage
Transformer$stop_transform_job(wait = TRUE)
Arguments
wait

wait for transform job


Method attach()

Attach an existing transform job to a new Transformer instance

Usage
Transformer$attach(transform_job_name, sagemaker_session = NULL)
Arguments
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.

Returns

Transformer (class): The Transformer instance with the specified transform job attached.


Method format()

format class

Usage
Transformer$format()

Method clone()

The objects of this class are cloneable with this method.

Usage
Transformer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-common documentation built on June 14, 2022, 10:31 p.m.