Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Databricks Unity Catalog for MLflow #2900

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
DATABRICKS_USERNAME = "DATABRICKS_USERNAME"
DATABRICKS_PASSWORD = "DATABRICKS_PASSWORD"
DATABRICKS_TOKEN = "DATABRICKS_TOKEN"
DATABRICKS_UNITY_CATALOG = "databricks-uc"


class MLFlowExperimentTracker(BaseExperimentTracker):
Expand Down Expand Up @@ -285,7 +286,6 @@ def configure_mlflow(self) -> None:
"""Configures the MLflow tracking URI and any additional credentials."""
tracking_uri = self.get_tracking_uri()
mlflow.set_tracking_uri(tracking_uri)
mlflow.set_registry_uri(tracking_uri)

if is_databricks_tracking_uri(tracking_uri):
if self.config.databricks_host:
Expand All @@ -296,6 +296,8 @@ def configure_mlflow(self) -> None:
os.environ[DATABRICKS_PASSWORD] = self.config.tracking_password
if self.config.tracking_token:
os.environ[DATABRICKS_TOKEN] = self.config.tracking_token
if self.config.enable_unity_catalog:
mlflow.set_registry_uri(DATABRICKS_UNITY_CATALOG)
else:
os.environ[MLFLOW_TRACKING_URI] = tracking_uri
if self.config.tracking_username:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class MLFlowExperimentTrackerConfig(
databricks_host: The host of the Databricks workspace with the MLflow
managed server to connect to. This is only required if
`tracking_uri` value is set to `"databricks"`.
enable_unity_catalog: If `True`, will enable the Databricks Unity Catalog for
logging and registering models.
"""

tracking_uri: Optional[str] = None
Expand All @@ -106,6 +108,7 @@ class MLFlowExperimentTrackerConfig(
tracking_token: Optional[str] = SecretField(default=None)
tracking_insecure_tls: bool = False
databricks_host: Optional[str] = None
enable_unity_catalog: bool = False

@model_validator(mode="after")
def _ensure_authentication_if_necessary(
Expand Down
Loading