PipelineModel(models, role, predictor_cls=None, name=None, vpc_config=None, sagemaker_session=None)¶
A pipeline of SageMaker
Model``s that can be deployed to an ``Endpoint.
Initialize an SageMaker
Modelwhich can be used to build an Inference Pipeline comprising of multiple model containers.
models (list[sagemaker.Model]) – For using multiple containers to build an inference pipeline, you can pass a list of
sagemaker.Modelobjects in the order you want the inference to happen.
role (str) – An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if it needs to access an AWS resource.
predictor_cls (callable[string, sagemaker.session.Session]) – A function to call to create a predictor (default: None). If not None,
deploywill return the result of invoking this function on the created endpoint name.
name (str) – The model name. If None, a default model name will be selected on each
sagemaker_session (sagemaker.session.Session) – A SageMaker Session object, used for SageMaker interactions (default: None). If not specified, one is created using the default AWS configuration chain.
Return a dict created by
sagemaker.pipeline_container_def()for deploying this model to a specified instance type.
Subclasses can override this to provide custom container definitions for deployment to a specific instance type. Called by
deploy(initial_instance_count, instance_type, endpoint_name=None, tags=None, wait=True, update_endpoint=False, data_capture_config=None)¶
Endpointand optionally return a
Create a SageMaker
EndpointConfig, and deploy an
self.predictor_clsis not None, this method returns a the result of invoking
self.predictor_clson the created endpoint name.
The name of the created model is accessible in the
namefield of this
Modelafter deploy returns
The name of the created endpoint is accessible in the
endpoint_namefield of this
Modelafter deploy returns.
initial_instance_count (int) – The initial number of instances to run in the
Endpointcreated from this
instance_type (str) – The EC2 instance type to deploy this Model to. For example, ‘ml.p2.xlarge’.
endpoint_name (str) – The name of the endpoint to create (default: None). If not specified, a unique endpoint name will be created.
wait (bool) – Whether the call should wait until the deployment of model completes (default: True).
update_endpoint (bool) – Flag to update the model in an existing Amazon SageMaker endpoint. If True, this will deploy a new EndpointConfig to an already existing endpoint and delete resources corresponding to the previous EndpointConfig. If False, a new endpoint will be created. Default: False
data_capture_config (sagemaker.model_monitor.DataCaptureConfig) – Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.
self.predictor_clson the created endpoint name, if
self.predictor_clsis not None. Otherwise, return None.
- Return type
transformer(instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, volume_kms_key=None)¶
Transformerthat uses this Model.
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.
env (dict) – Environment variables to be set for use during the transform job (default: None).
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.
volume_kms_key (str) – Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).
Delete the SageMaker model backing this pipeline model. This does not delete the list of SageMaker models used in multiple containers to build the inference pipeline.