Skip to content

Commit

Permalink
client_utils.py: improved create_mlflow_client() logic and unused is_…
Browse files Browse the repository at this point in the history
…unity_catalog()
  • Loading branch information
amesar committed May 5, 2024
1 parent 5244d36 commit 7b31821
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions mlflow_export_import/client/client_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import mlflow
from . http_client import HttpClient, MlflowHttpClient, DatabricksHttpClient

Expand Down Expand Up @@ -28,16 +27,10 @@ def create_mlflow_client():
"""
Create MLflowClient. If MLFLOW_TRACKING_URI is UC, then set MlflowClient.tracking_uri to the non-UC variant.
"""
tracking_uri = os.environ.get("MLFLOW_TRACKING_URI")
if tracking_uri:
nonuc_tracking_uri = tracking_uri.replace("databricks-uc","databricks")
return mlflow.MlflowClient(nonuc_tracking_uri, tracking_uri)
registry_uri = mlflow.get_registry_uri()
if registry_uri:
tracking_uri = mlflow.get_tracking_uri()
nonuc_tracking_uri = tracking_uri.replace("databricks-uc","databricks") # NOTE: legacy
return mlflow.MlflowClient(nonuc_tracking_uri, registry_uri)
else:
return mlflow.MlflowClient()


def is_unity_catalog():
UC_VALUE = "databricks-uc"
env_var = os.environ.get("MLFLOW_REGISTRY_URI")
api_val = mlflow.get_registry_uri()
return (env_var and env_var.startswith(UC_VALUE)) or (api_val and api_val.startswith(UC_VALUE))

0 comments on commit 7b31821

Please sign in to comment.