Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SageMaker delete Models and Endpoint configurations with python API

I've tried deleting/recreating endpoints with the same name, and wasted a lot of time before I realized that changes do not get applied unless you also delete the corresponding Model and Endpoint configuration so that new ones can be created with that name.

Is there a way with the sagemaker python api to delete all three instead of just the endpoint?

like image 402
Austin Avatar asked Jul 23 '26 07:07

Austin


2 Answers

I believe you are looking for something like this? :

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.delete_endpoint_config

Examples:

import boto3

deployment_name = 'my_deployment_name'
client = boto3.client('sagemaker')
response = client.describe_endpoint_config(EndpointConfigName=deployment_name)
model_name = response['ProductionVariants'][0]['ModelName']
client.delete_model(ModelName=model_name)    
client.delete_endpoint(EndpointName=deployment_name)
client.delete_endpoint_config(EndpointConfigName=deployment_name)
like image 183
Robert Penridge Avatar answered Jul 24 '26 22:07

Robert Penridge


It looks like AWS is currently in the process of supporting model deletion via API with this pull request.

For the time being Amazon's only recommendation is to delete everything via the console.

If this is critical to your system you can probably manage everything via Cloud Formation and create/delete services containing your Sagemaker models and endpoints.

like image 32
Kerri Avatar answered Jul 24 '26 20:07

Kerri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!