in sagemaker-pyspark-sdk/src/sagemaker_pyspark/SageMakerModel.py [0:0]
def fromModelS3Path(cls,
modelPath,
modelImage,
modelExecutionRoleARN,
endpointInstanceType,
endpointInitialInstanceCount,
requestRowSerializer,
responseRowDeserializer,
modelEnvironmentVariables=None,
endpointCreationPolicy=EndpointCreationPolicy.CREATE_ON_CONSTRUCT,
sagemakerClient=SageMakerClients.create_sagemaker_client(),
prependResultRows=True,
namePolicy=RandomNamePolicy(),
uid="sagemaker"):
""" Creates a JavaSageMakerModel from existing model data in S3.
The returned JavaSageMakerModel can be used to transform Dataframes.
Args:
modelPath (str): The S3 URI to the model data to host.
modelImage (str): The URI of the image that will serve model inferences.
modelExecutionRoleARN (str): The IAM Role used by SageMaker when running the hosted
Model and to download model data from S3.
endpointInstanceType (str): The instance type used to run the model container.
endpointInitialInstanceCount (int): The initial number of instances used to host the
model.
requestRowSerializer (RequestRowSerializer): Serializes a row to an array of bytes.
responseRowDeserializer (ResponseRowDeserializer): Deserializes an array of bytes to a
series of rows.
modelEnvironmentVariables: The environment variables that SageMaker will set on the
model container during execution.
endpointCreationPolicy (EndpointCreationPolicy): Whether the endpoint is created upon
SageMakerModel construction, transformation, or not at all.
sagemakerClient (AmazonSageMaker) Amazon SageMaker client. Used to send
CreateTrainingJob, CreateModel, and CreateEndpoint requests.
prependResultRows (bool): Whether the transformation result should also include the
input Rows. If true, each output Row is formed by a concatenation of the input Row
with the corresponding Row produced by SageMaker invocation, produced by
responseRowDeserializer. If false, each output Row is just taken from
responseRowDeserializer.
namePolicy (NamePolicy): The NamePolicy to use when naming SageMaker entities created
during usage of the returned model.
uid (String): The unique identifier of the SageMakerModel. Used to represent the stage
in Spark ML pipelines.
Returns:
JavaSageMakerModel:
A JavaSageMakerModel that sends InvokeEndpoint requests to an endpoint hosting
the training job's model.
"""
scala_function = "%s.fromModelS3Path" % SageMakerModel._wrapped_class
if modelEnvironmentVariables is None:
modelEnvironmentVariables = {}
model_java_obj = SageMakerJavaWrapper()._new_java_obj(
scala_function,
modelPath,
modelImage,
modelExecutionRoleARN,
endpointInstanceType,
endpointInitialInstanceCount,
requestRowSerializer,
responseRowDeserializer,
modelEnvironmentVariables,
endpointCreationPolicy,
sagemakerClient,
prependResultRows,
namePolicy,
uid)
return SageMakerModel(
endpointInstanceType=endpointInstanceType,
endpointInitialInstanceCount=endpointInitialInstanceCount,
requestRowSerializer=requestRowSerializer,
responseRowDeserializer=responseRowDeserializer,
javaObject=model_java_obj)