Is it possible to use Redshift ML with a Sagemaker multi-container model?
The closest I can find is the documentation that mentions the syntax for BYOM remote inference (https://docs.aws.amazon.com/redshift/latest/dg/r_create_model_use_cases.html):
CREATE MODEL model_name
FUNCTION function_name ( data_type [, ...] )
RETURNS data_type
SAGEMAKER 'endpoint_name'[:'model_name']
IAM_ROLE { default };
Which specifies a model_name
parameter. However, I'm dealing with a single Sagemaker model with multiple containers, running in Direct
mode.
For reference, referencing a specific container is possible using boto3 (I'm dapting the example from here: https://docs.aws.amazon.com/sagemaker/latest/dg/neo-requests-boto3.html):
import boto3
import json
endpoint = 'insert name of your endpoint here'
runtime = boto3.Session().client('sagemaker-runtime')
# Read image into memory
with open(image, 'rb') as f:
payload = f.read()
# Send image via InvokeEndpoint API
response = runtime.invoke_endpoint(
EndpointName=endpoint,
ContentType='application/x-image',
Body=payload,
TargetContainerHostname='my-container' # Here I would specify each individual container.
)
# Unpack response
result = json.loads(response['Body'].read().decode())
I have a question regarding first part of your question, multimodel endpoints. When I try to create a model in redshift as below:
CREATE MODEL public.test_model FUNCTION f_test_model(float,float,float,float,float,float,float) RETURNS decimal(10,6) SAGEMAKER 'multimodel-endpoint-test-model':'test_model_1.tar.gz' IAM_ROLE 'arn:aws:iam::xxxxxxxxxxxxx:role/RedshiftML';
I get an error: ERROR: syntax error at or near ":" Position: 244 [ErrorId: 1-62f9c1ea-630b6de304a036c97fee2e4c]
Isn't this the correct syntax? If not, do you know the correct syntax as I cannot find anything in the documentation or in the examples