Skip to content

Exception messages raised in input_fn are not shown after invoke_endpoint raises an error #2067

Description

@MichalShuviPowtoon

Hi,
I'm using SKLearn estimator and my inference script contains something like:

def predict_fn(input_data, model):
    a = input_data.get('a')
    if asset_type and type(a) != str:
        raise Exception(f'The asset type must be a string, not {type(asset_type).__name__}')

after running the following code with a false body, e.g. a = [a, b, c]:

client = boto3.client('sagemaker-runtime')
try:
    response = client.invoke_endpoint(
           EndpointName=endpoint_name, 
           Body=body, 
           ContentType='application/json')
except client.exceptions.ModelError as e:
  print(e.response)

I get:
{'Error': {'Message': 'Received server error (500) from model with message "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>500 Internal Server Error</title>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>\n"..... }

Why can't I see my exception message in the output as written in input_fn? (in the cloudWatch console it is shown)

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions