- Newest
- Most votes
- Most comments
So as you saw already, the SageMaker Studio "Test inference" UI currently only supports JSON format... But this is a constraint of the UI, not your endpoint.
If you want to test your deployed endpoint with non-JSON data, you can do this from code (e.g. from a notebook):
- Using the
sagemaker
Python SDK, create a Predictor specifying your endpoint name and the relevant de/serializers (fromsagemaker.(de)serializers
- for example sagemaker.serializers.CSVSerializer). Then callpredictor.predict(data)
. - Using a
boto3.
client("sagemaker-runtime"), serialize your data to required format yourself (e.g."M,3,5,7,45,34,23,76"
) and then callinvoke_endpoint()
.
This would be necessary if you're using a pre-built algorithm that doesn't support JSON as a request/response format. Since you're using the Abalone pipeline example, I guess it's likely you're using XGBoost as a pre-built SageMaker algorithm?
Alternatively, if you're building a custom algorithm with your own training script OR would be interested in using XGBoost as a script-mode framework - more information in the SageMaker SDK doc), you may like to extend your algorithm to accept application/json
requests and return JSON responses.
The process for this will vary a little by framework, but should be documented here for XGBoost. Essentially, you'll want to provide a script file e.g. inference.py
which defines special functions input_fn()
and output_fn()
. You can provide implementations of these functions that accept application/json
content types and de/serialize appropriately.
That way you could make your deployed endpoint support JSON format and therefore be able to use the test UI in SageMaker Studio.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
Thanks, that's super helpful - we've successfully used a boto3 client from a notebook in sagemaker to hit the endpoint based on your suggestion.
What we'd really love to do is to be able to hit the endpoint from another machine outside sagemaker, e.g. on our dev machines or dev servers. Is there any documentation on that? We see this on StackOverflow https://stackoverflow.com/a/64907595/316729 that suggests one might pass AWS keys etc. into the boto3 client, but would love to see the official docs on the right way to do this.
Many thanks in advance