MultiDataModel: MultiDataModel Class

MultiDataModelR Documentation

MultiDataModel Class

Description

A SageMaker “MultiDataModel“ that can be used to deploy multiple models to the same SageMaker “Endpoint“, and also deploy additional models to an existing SageMaker multi-model “Endpoint“

Super classes

sagemaker.mlcore::ModelBase -> sagemaker.mlcore::Model -> MultiDataModel

Methods

Public methods

Inherited methods

Method new()

Initialize a “MultiDataModel“. In addition to these arguments, it supports all arguments supported by “Model“ constructor

Usage
MultiDataModel$new(
  name,
  model_data_prefix,
  model = NULL,
  image_uri = NULL,
  role = NULL,
  sagemaker_session = NULL,
  ...
)
Arguments
name

(str): The model name.

model_data_prefix

(str): The S3 prefix where all the models artifacts (.tar.gz) in a Multi-Model endpoint are located

model

(sagemaker.Model): The Model object that would define the SageMaker model attributes like vpc_config, predictors, etc. If this is present, the attributes from this model are used when deploying the “MultiDataModel“. Parameters 'image_uri', 'role' and 'kwargs' are not permitted when model parameter is set.

image_uri

(str): A Docker image_uri URI. It can be null if the 'model' parameter is passed to during “MultiDataModel“ initialization (default: None)

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 some AWS resources. It can be null if this is being used to create a Model to pass to a “PipelineModel“ which has its own Role field or if the 'model' parameter is passed to during “MultiDataModel“ initialization (default: None)

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.

...

: Keyword arguments passed to the :class:'~sagemaker.model.Model' initializer. .. tip:: You can find additional parameters for initializing this class at :class:'~sagemaker.model.Model'.


Method prepare_container_def()

Return a container definition set with MultiModel mode, model data and other parameters from the model (if available). Subclasses can override this to provide custom container definitions for deployment to a specific instance type. Called by “deploy()“.

Usage
MultiDataModel$prepare_container_def(
  instance_type = NULL,
  accelerator_type = NULL
)
Arguments
instance_type

(str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'.

accelerator_type

(str): The Elastic Inference accelerator type to deploy to the instance for loading and making inferences to the model. For example, 'ml.eia1.medium'.

Returns

dict[str, str]: A complete container definition object usable with the CreateModel API


Method deploy()

Deploy this “Model“ to an “Endpoint“ and optionally return a “Predictor“. Create a SageMaker “Model“ and “EndpointConfig“, and deploy an “Endpoint“ from this “Model“. If self.model is not None, then the “Endpoint“ will be deployed with parameters in self.model (like vpc_config, enable_network_isolation, etc). If self.model is None, then use the parameters in “MultiDataModel“ constructor will be used. If “self.predictor_cls“ is not None, this method returns a the result of invoking “self.predictor_cls“ on the created endpoint name. The name of the created model is accessible in the “name“ field of this “Model“ after deploy returns The name of the created endpoint is accessible in the “endpoint_name“ field of this “Model“ after deploy returns.

Usage
MultiDataModel$deploy(
  initial_instance_count,
  instance_type,
  serializer = NULL,
  deserializer = NULL,
  accelerator_type = NULL,
  endpoint_name = NULL,
  tags = NULL,
  kms_key = NULL,
  wait = TRUE,
  data_capture_config = NULL
)
Arguments
initial_instance_count

(int): The initial number of instances to run in the “Endpoint“ created from this “Model“.

instance_type

(str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge', or 'local' for local mode.

serializer

(:class:'~sagemaker.serializers.BaseSerializer'): A serializer object, used to encode data for an inference endpoint (default: None). If “serializer“ is not None, then “serializer“ will override the default serializer. The default serializer is set by the “predictor_cls“.

deserializer

(:class:'~sagemaker.deserializers.BaseDeserializer'): A deserializer object, used to decode data from an inference endpoint (default: None). If “deserializer“ is not None, then “deserializer“ will override the default deserializer. The default deserializer is set by the “predictor_cls“.

accelerator_type

(str): Type of Elastic Inference accelerator to deploy this model for model loading and inference, for example, 'ml.eia1.medium'. If not specified, no Elastic Inference accelerator will be attached to the endpoint. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

endpoint_name

(str): The name of the endpoint to create (default: None). If not specified, a unique endpoint name will be created.

tags

(List[dict[str, str]]): The list of tags to attach to this specific endpoint.

kms_key

(str): The ARN of the KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

wait

(bool): Whether the call should wait until the deployment of this model completes (default: True).

data_capture_config

(sagemaker.model_monitor.DataCaptureConfig): Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

Returns

callable[string, sagemaker.session.Session] or None: Invocation of “self.predictor_cls“ on the created endpoint name, if “self.predictor_cls“ is not None. Otherwise, return None.


Method add_model()

Adds a model to the “MultiDataModel“ by uploading or copying the model_data_source artifact to the given S3 path model_data_path relative to model_data_prefix

Usage
MultiDataModel$add_model(model_data_source, model_data_path = NULL)
Arguments
model_data_source

: Valid local file path or S3 path of the trained model artifact

model_data_path

: S3 path where the trained model artifact should be uploaded relative to “self.model_data_prefix“ path. (default: None). If None, then the model artifact is uploaded to a path relative to model_data_prefix

Returns

str: S3 uri to uploaded model artifact


Method list_models()

Usage
MultiDataModel$list_models()
Returns

Generates and returns relative paths to model archives stored at model_data_prefix S3 location.


Method clone()

The objects of this class are cloneable with this method.

Usage
MultiDataModel$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-mlcore documentation built on May 3, 2022, 10:08 a.m.