- Newest
- Most votes
- Most comments
Yes, it is possible to specify different S3 paths for saving model results when making asynchronous inference calls to a SageMaker endpoint. When invoking an asynchronous endpoint, you can provide the S3 path where you want the results to be stored.
To do this, you use the InvokeEndpointAsync
API call. In this call, you can specify an InputLocation
parameter, which is the S3 URI of your input data. The response from this API call will include an OutputLocation
, which is where the results will be stored.
Here's a general approach to achieve this:
-
For each inference call, prepare your input data and upload it to a specific S3 location.
-
Use the
InvokeEndpointAsync
API, providing the S3 URI of your input data as theInputLocation
. -
The API call will return a response object that includes the
OutputLocation
where the results will be stored. -
You can then retrieve the results from this
OutputLocation
once the processing is complete.
Here's a simplified example of how you might structure this in Python using boto3:
import boto3 import uuid sagemaker_runtime = boto3.client("sagemaker-runtime", region_name="your-region") # Specify the S3 URI of the input input_location = "s3://your-bucket-name/input/data.csv" response = sagemaker_runtime.invoke_endpoint_async( EndpointName='your-endpoint-name', InputLocation=input_location, InferenceId=str(uuid.uuid4()), ContentType="text/csv" # Adjust based on your data type ) output_location = response['OutputLocation'] print(f"Results will be stored at: {output_location}")
By changing the input_location
for each call, you can effectively control where the results are stored, as the output location is typically based on the input location.
Remember that the exact implementation may vary depending on your specific use case and the configuration of your SageMaker endpoint. Always ensure that your IAM roles have the necessary permissions to read from and write to the specified S3 locations.
Sources
Asynchronous inference - Amazon SageMaker AI
Check prediction results - Amazon SageMaker AI