I have a TensorFlow Model deployed with AWS SageMaker endpoint exposed . From Lambda Python I am using boto3 client to invoke the endpoint . The TensorFlow model accepts 3 inputs as follows
{'input1' : numpy array , 'input2' : integer ,'input3' :numpy array }
From Lambda using runtime.invoke_endpoint to invoke the SageMaker endpoint . Getting the error as Parse Error when the API is invoked from boto3client I tried serializing the data into csv format before calling the API endpoint
Below code written in Lambda
payload = {'input1': encoded_enc_inputstanza_in_batch,
'input2' : encoded_enc_inputstanza_in_batch.shape[1],
'input3' : np.reshape([[15]*20],20) }
infer_file = io.StringIO()
writer = csv.writer(infer_file)
for key, value in payload.items():
writer.writerow([key, value])
response = runtime.invoke_endpoint(EndpointName=ENDPOINT_NAME,
ContentType='text/csv',
Body=infer_file.getvalue())
Additional Details These are the additional details - Sagemaker Model expects 3 fields as input - 'input1' - Numpy array 'input2' - Int data type , 'input3' - numpy array
Actual result -
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 143, in lambda_handler
Body=infer_file.getvalue())
File "/var/runtime/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 623, in _make_api_call
raise error_class(parsed_response, operation_name)
END RequestId: fa70e1f3-763b-41be-ad2d-76ae80aefcd0
Expected Result - Successful invocation of the API endpoint .