<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Update model serving endpoint in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/58649#M2918</link>
    <description>&lt;P&gt;I was also searching for a solution to this problem when I came across your similar issue. This approach seems to work well. It either updates the config of the existing endpoint, or creates a new one if it doesn't exist.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Define the endpoint config
data = {
    "name": endpoint_name,
    "config": {
        "served_models": [
            {
                "model_name": model_name,
                "model_version": model_version,
                "workload_size": "Small",
                "scale_to_zero_enabled": True,
                "environment_vars": {
                    "OPENAI_API_KEY": f"{{{{secrets/{secret_scope_name}/{secret_key_name}}}}}"
                }
            }
        ]
    }
}

# Get list of active endpoints
endpoint_list_response = requests.get(
    url=f"https://{db_host_url}/api/2.0/serving-endpoints",
    headers=headers
)

# Check if endpoint already exists
endpoints = endpoint_list_response.json().get("endpoints", [])
endpoint_exists = any(ep['name'] == endpoint_name for ep in endpoints)
print("Endpoint exists:", endpoint_exists)

# Update endpoint config if it exists
if endpoint_exists:
    update_response = requests.put(
        url=f"https://{db_host_url}/api/2.0/serving-endpoints/{endpoint_name}/config",
        json=data["config"],
        headers=headers
    )

    print("Update Response status:", update_response.status_code)
    print("Update Response text:", update_response.text, "\n")

# Create endpoint if it doesn't exist
else:
    create_response = requests.post(
        url=f"https://{db_host_url}/api/2.0/serving-endpoints",
        json=data,
        headers=headers
    )

    print("Create Response status:", create_response.status_code)
    print("Create Response text:", create_response.text, "\n")&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 30 Jan 2024 05:30:35 GMT</pubDate>
    <dc:creator>Aaron12</dc:creator>
    <dc:date>2024-01-30T05:30:35Z</dc:date>
    <item>
      <title>Update model serving endpoint</title>
      <link>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/58608#M2916</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I've been able to create a model serving endpoint through the api, following the &lt;A href="https://docs.databricks.com/api/workspace/servingendpoints/create" target="_self"&gt;docs&lt;/A&gt;, but then when trying to update the version, I get the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;'{"error_code":"RESOURCE_ALREADY_EXISTS","message":"Endpoint with name \'ml-project\' already exists."}'&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;BR /&gt;Appreciate you help and insights.&lt;BR /&gt;Thanks&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Jan 2024 12:48:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/58608#M2916</guid>
      <dc:creator>pablobd</dc:creator>
      <dc:date>2024-01-29T12:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update model serving endpoint</title>
      <link>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/58649#M2918</link>
      <description>&lt;P&gt;I was also searching for a solution to this problem when I came across your similar issue. This approach seems to work well. It either updates the config of the existing endpoint, or creates a new one if it doesn't exist.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Define the endpoint config
data = {
    "name": endpoint_name,
    "config": {
        "served_models": [
            {
                "model_name": model_name,
                "model_version": model_version,
                "workload_size": "Small",
                "scale_to_zero_enabled": True,
                "environment_vars": {
                    "OPENAI_API_KEY": f"{{{{secrets/{secret_scope_name}/{secret_key_name}}}}}"
                }
            }
        ]
    }
}

# Get list of active endpoints
endpoint_list_response = requests.get(
    url=f"https://{db_host_url}/api/2.0/serving-endpoints",
    headers=headers
)

# Check if endpoint already exists
endpoints = endpoint_list_response.json().get("endpoints", [])
endpoint_exists = any(ep['name'] == endpoint_name for ep in endpoints)
print("Endpoint exists:", endpoint_exists)

# Update endpoint config if it exists
if endpoint_exists:
    update_response = requests.put(
        url=f"https://{db_host_url}/api/2.0/serving-endpoints/{endpoint_name}/config",
        json=data["config"],
        headers=headers
    )

    print("Update Response status:", update_response.status_code)
    print("Update Response text:", update_response.text, "\n")

# Create endpoint if it doesn't exist
else:
    create_response = requests.post(
        url=f"https://{db_host_url}/api/2.0/serving-endpoints",
        json=data,
        headers=headers
    )

    print("Create Response status:", create_response.status_code)
    print("Create Response text:", create_response.text, "\n")&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Jan 2024 05:30:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/58649#M2918</guid>
      <dc:creator>Aaron12</dc:creator>
      <dc:date>2024-01-30T05:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update model serving endpoint</title>
      <link>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/59036#M2938</link>
      <description>&lt;P&gt;Folks, Alternate way you can also deploy the models in serving layer with different versions. Though I am using mLflow.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may also refer to the below link if it its helpful&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.databricks.com/blog/2020/11/02/quickly-deploy-test-and-manage-ml-models-as-rest-endpoints-with-mlflow-model-serving-on-databricks.html" target="_blank"&gt;How to Quickly Deploy, Test &amp;amp; Manage ML Models as REST Endpoints with Databricks - The Databricks Blog&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 08:57:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/update-model-serving-endpoint/m-p/59036#M2938</guid>
      <dc:creator>BR_DatabricksAI</dc:creator>
      <dc:date>2024-02-02T08:57:30Z</dc:date>
    </item>
  </channel>
</rss>

