databricks-sdk-py icon indicating copy to clipboard operation
databricks-sdk-py copied to clipboard

[FEATURE] add serving_endpoints.create_or_update[_and_wait] functions

Open QuentinAmbard opened this issue 1 year ago • 3 comments

Problem Statement We often have to create or update an endpoint. Currently we do things like this which is a lot of code:

existing_endpoint = next(
    (e for e in w.serving_endpoints.list() if e.name == serving_endpoint_name), None
)
serving_endpoint_url = f"{host}/ml/endpoints/{serving_endpoint_name}"
if existing_endpoint == None:
    print(f"Creating the endpoint {serving_endpoint_url}, this will take a few minutes to package and deploy the endpoint...")
    w.serving_endpoints.create_and_wait(name=serving_endpoint_name, config=endpoint_config)
else:
    print(f"Updating the endpoint {serving_endpoint_url} to version {latest_model_version}, this will take a few minutes to package and deploy the endpoint...")
    w.serving_endpoints.update_config_and_wait(served_models=endpoint_config.served_models, name=serving_endpoint_name)

Proposed Solution Instead we could add functions such as w.serving_endpoints.create_or_update(xxx) or w.serving_endpoints.create_or_update_and_wait(xxx)

QuentinAmbard avatar May 28 '24 21:05 QuentinAmbard

I am also longing for this kind of function!

moritzmeister avatar Jun 14 '24 08:06 moritzmeister

At least having an endpoint_exists function would be a good first step.

QuentinAmbard avatar Jun 16 '24 17:06 QuentinAmbard

alternative to iteration

def does_serving_endpoint_already_exist(self, endpoint_name):
    try:
        workspace_client.serving_endpoints.get(endpoint_name)
    except DatabricksError as error:
        if error.error_code == "RESOURCE_DOES_NOT_EXIST":
            return False
        else:
            raise error
    return True

ppiotrow avatar Jul 31 '24 14:07 ppiotrow