Skip to content

Commit

Permalink
Merge pull request #81 from databricks-industry-solutions/fix/serving…
Browse files Browse the repository at this point in the history
…_secret

Added token creation and secret, minor fix to time.sleep
  • Loading branch information
erinaldidb authored Nov 19, 2024
2 parents 7b11d5f + d4dd327 commit 9cd56ca
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion monailabel_model/ModelServing.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,28 @@

# COMMAND ----------

# MAGIC %md
# MAGIC ## Creating a personal token and assign it to a secret
# MAGIC
# MAGIC The next cell demonstrates how to create a personal access token (PAT) and store it securely in Databricks secrets. This token will be used for api calls authentication in the monailabel server to Volumes and SQL Warehouses.

# COMMAND ----------

from databricks.sdk import WorkspaceClient

w = WorkspaceClient()

scope_name = "pixels-scope"

if scope_name not in [scope.name for scope in w.secrets.list_scopes()]:
w.secrets.create_scope(scope=scope_name)

token = w.tokens.create(comment=f'pixels_serving_endpoint_token')

w.secrets.put_secret(scope=scope_name, key="pixels_token", string_value=token.token_value)

# COMMAND ----------

# MAGIC %md
# MAGIC # Model Deployment with MLflow on Databricks
# MAGIC
Expand Down Expand Up @@ -259,7 +281,7 @@

while client.get_endpoint(serving_endpoint_name).state.ready != 'READY':
print("ENDPOINT NOT READY YET")
time.sleet(60)
time.sleep(60)

client.predict(
endpoint=serving_endpoint_name,
Expand Down

0 comments on commit 9cd56ca

Please sign in to comment.