forked from aws/sagemaker-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup_endpoints.py
More file actions
36 lines (26 loc) · 1.3 KB
/
Copy pathcleanup_endpoints.py
File metadata and controls
36 lines (26 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import boto3
def cleanup_endpoints():
"""Delete existing SageMaker endpoints and configurations."""
sagemaker_client = boto3.client('sagemaker')
# List all endpoints
print("🔍 Finding existing endpoints...")
endpoints = sagemaker_client.list_endpoints()
for endpoint in endpoints['Endpoints']:
endpoint_name = endpoint['EndpointName']
status = endpoint['EndpointStatus']
print(f"📍 Found endpoint: {endpoint_name} ({status})")
if 'llama' in endpoint_name.lower():
try:
print(f"🗑️ Deleting endpoint: {endpoint_name}")
sagemaker_client.delete_endpoint(EndpointName=endpoint_name)
print(f"✅ Endpoint {endpoint_name} deletion initiated")
# Also delete the endpoint configuration
print(f"🗑️ Deleting endpoint config: {endpoint_name}")
sagemaker_client.delete_endpoint_config(EndpointConfigName=endpoint_name)
print(f"✅ Endpoint config {endpoint_name} deleted")
except Exception as e:
print(f"❌ Error deleting {endpoint_name}: {e}")
print("🎯 Cleanup complete!")
if __name__ == "__main__":
cleanup_endpoints()