I am trying to implement sagemaker async with my own model based endpoint.
To invoke the service in the container, I used invoke_endpoint_async function. Here is the code:
input_location = "S3://xxxxxx/xxx/xxx.vtk"
resp = sagemaker_runtime.invoke_endpoint_async(
EndpointName=endpoint_name_async,
InputLocation=input_location,
CustomAttributes=json.dumps({"test_key": "test_value"})
)
In the container, I am trying to retrieving those information. Here is the code:
@app.route("/invocations", methods=["POST"])
async def invocation_handler(req):
if req.headers is not None:
custom_attribute = json.loads(req.headers.get("x-amzn-sagemaker-custom-attributes"))
# ... ...
This is the only way I can find to retrieve the CustomAttributes from the request and I don't know where is the InputLocation or where is the input file. req
has an attribute called req.files
. But it is empty.
Can someone help me figure this out? All I want to do is retrieve the input data stored in S3 and do further process in the container as the endpoint.