Skip to content

Commit

Permalink
add an example to create serving endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
s-udhaya committed Sep 27, 2023
1 parent 3492167 commit a25c00b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/serving/create_serving_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import (EndpointCoreConfigInput, Route, ServedModelInput, TrafficConfig)

w = WorkspaceClient()

served_model_1 = ServedModelInput(model_name="model_name",
model_version="model_version",
workload_size="Small",
scale_to_zero_enabled=True)
served_model_2 = ServedModelInput(model_name="model_name",
model_version="model_version",
workload_size="Small",
scale_to_zero_enabled=True)

route_1 = Route(served_model_name=f"{served_model_1.model_name}-{served_model_1.model_version}",
traffic_percentage=50)
route_2 = Route(served_model_name=f"{served_model_2.model_name}-{served_model_2.model_version}",
traffic_percentage=50)

traffic_config = TrafficConfig(routes=[route_1, route_2])

endpoint_config = EndpointCoreConfigInput(served_models=[served_model_1, served_model_2],
traffic_config=traffic_config)

w.serving_endpoints.create_and_wait(name="endpoint-name", config=endpoint_config)

0 comments on commit a25c00b

Please sign in to comment.