def clean_up_endpoints()

in right_size_your_sagemaker_endpoints/sagemaker_helper.py [0:0]


def clean_up_endpoints(endpoints_list):
    """
    Deletes a given list of endpoints
    
    This function checks if a given endpoint exists, and if yes, 
    deletes the endpoint.
    
    Input:
    endpoints_list: list of endpoints to delete
    
    Output:
    None
    """
    endpoints = get_existing_endpoints()
    endpoints_list = list(set(endpoints_list))  # avoiding duplicates
    for endpoint in endpoints_list:
        if endpoint in endpoints:
            try:
                print(f'Deleting {endpoint}..')
                sm_client.delete_endpoint(
                    EndpointName=endpoint
                )
            except Exception as e:
                print(f"Error deleting endpoint {endpoint}: {e}")