Error with invoking a Deployed InService SageMaker Canvas ML Model Endpoint: Received Server Error (500) from primary and could not load the entire response body.


Hey, so I am trying to make requests and receive responses from an Endpoint that I have deployed for an ML Model that I have made on SageMaker Canvas, through my Flask Web Application.

This is the code on my Flask Application as of now:

Initialize the SageMaker client

    client = boto3.client("runtime.sagemaker", aws_access_key_id=AWS_ACCESS_KEY, aws_secret_access_key=AWS_SECRET_KEY, region_name=AWS_REGION)

Create a list of lists where the first list represents column names and the second list represents values

    data = [['artist', 'album'], ['Happy', 0.843]]

    # Create a DataFrame from the list of lists
    df = pd.DataFrame([data[1]], columns=data[0])

    # Convert DataFrame to CSV format
    csv_data = df.to_csv(header=False, index=False).encode("utf-8")

Invoke the SageMaker endpoint with the modified input data

    response = client.invoke_endpoint(

But, the error received is:

botocore.errorfactory.ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from primary and could not load the entire response body.

The Endpoint is InService too.

Any help at all is much appreciated. Thanks so so much, in advance.

preguntada hace 4 meses754 visualizaciones
1 Respuesta


So the issue here is most likely with your inference code and how you are parsing/transforming the data coming in. Your endpoint is up and running but the format in which you are feeding it data is confusing it. The endpoint is expecting encoded data thus you need to convert your payload into the appropriate data format, there are two manners in which you can approach this.

Use a serializer, when creating your endpoint with the predictor class you want to use the SageMaker Serializer to automatically encode/decode your data, this is configured while creating your endpoint.

If you choose not to use the serializer you want to encode the data on your own using something such as json.dumps(payload) to encode your data properly before sending the data to the endpoint.

Extra Resources: SageMaker Serializers:

Hope this helps!

respondido hace 3 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas