in sagemaker-pyspark-sdk/src/sagemaker_pyspark/SageMakerModel.py [0:0]
def fromEndpoint(cls,
endpointName,
requestRowSerializer,
responseRowDeserializer,
modelEnvironmentVariables=None,
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:
endpointName (str): The name of an endpoint that is currently in service.
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.
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.fromEndpoint" % SageMakerModel._wrapped_class
if modelEnvironmentVariables is None:
modelEnvironmentVariables = {}
model_java_obj = SageMakerJavaWrapper()._new_java_obj(
scala_function,
endpointName,
requestRowSerializer,
responseRowDeserializer,
modelEnvironmentVariables,
sagemakerClient,
prependResultRows,
namePolicy,
uid)
return SageMakerModel(
endpointInstanceType=None,
endpointInitialInstanceCount=None,
requestRowSerializer=requestRowSerializer,
responseRowDeserializer=responseRowDeserializer,
javaObject=model_java_obj)