amazon-sagemaker-examples
amazon-sagemaker-examples copied to clipboard
Lambda not able to invoke AWS sagemaker endpoint
predict = [0.1,0.2]
payload = {
"instances": [
{
"features": predict
}
]
}
is the payload is used to invoke endpoint within sagemaker notebook instance and I am able to get inference results back.
But when I try to use the same format to invoke the endpoint in lambda as below,
`import json
import io
import boto3
client = boto3.client('runtime.sagemaker')
def lambda_handler(event, context):
print("Received event: " + json.dumps(event, indent=2))
#data = json.loads(json.dumps(event))
#payload = data['data']
print(json.dumps(event))
response = client.invoke_endpoint(EndpointName='linear-learner-2019-12-12-16-20-56-788',
ContentType='application/json',
Body=(json.dumps(event)))
return response`
I am facing the following error,
Received event: {
"instances": [
{
"features": [
0.1,
0.2
]
}
]
}
{"instances": [{"features": [0.1, 0.2]}]}
An error occurred during JSON serialization of response: <botocore.response.StreamingBody object at 0x7f53918e2828> is not JSON serializable