Skip to content

Commit 63f96cc

Browse files
harupyruoxuany
and
ruoxuany
authored
Cherry picks for mlflow 1.12.1 (mlflow#3717)
* Do not disable existing logger when init alembic (mlflow#3653) Signed-off-by: ruoxuany <ruoxuan.yin@citrix.com> Co-authored-by: ruoxuany <ruoxuan.yin@citrix.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Only import matplotlib where necessary for artifact plotting (mlflow#3703) * Only import matplotlib where necessary for artifact plotting Signed-off-by: Corey Zumar <corey.zumar@databricks.com> * Silly change for formatter Signed-off-by: Corey Zumar <corey.zumar@databricks.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> * Fix run_link for cross-workspace model versions (mlflow#3681) Fix run_link for cross-workspace model versions Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> Co-authored-by: ruoxuany <ruoxuan.yin@citrix.com>
1 parent f56a4a7 commit 63f96cc

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

mlflow/sklearn/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import inspect
55
import logging
66
from numbers import Number
7-
import matplotlib.pyplot as plt
87
import numpy as np
98
import time
109

@@ -500,6 +499,8 @@ def _log_specialized_estimator_content(fitted_estimator, run_id, fit_args, fit_k
500499
display.ax_.set_title(artifact.title)
501500
filepath = tmp_dir.path("{}.png".format(artifact.name))
502501
display.figure_.savefig(filepath)
502+
import matplotlib.pyplot as plt
503+
503504
plt.close(display.figure_)
504505
except Exception as e: # pylint: disable=broad-except
505506
_log_warning_for_artifacts(artifact.name, artifact.function, e)

mlflow/store/db_migrations/env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Interpret the config file for Python logging.
1313
# This line sets up loggers basically.
14-
fileConfig(config.config_file_name)
14+
fileConfig(config.config_file_name, disable_existing_loggers=False)
1515

1616
# add your model's MetaData object here
1717
# for 'autogenerate' support

mlflow/utils/databricks_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def get_job_type():
164164

165165

166166
def get_webapp_url():
167-
"""Should only be called if is_in_databricks_notebook is true"""
167+
"""Should only be called if is_in_databricks_notebook or is_in_databricks_jobs is true"""
168168
url = _get_property_from_spark_context("spark.databricks.api.url")
169169
if url is not None:
170170
return url
@@ -191,7 +191,8 @@ def get_browser_hostname():
191191
def get_workspace_info_from_dbutils():
192192
dbutils = _get_dbutils()
193193
if dbutils:
194-
workspace_host = get_browser_hostname()
194+
browser_hostname = get_browser_hostname()
195+
workspace_host = "https://" + browser_hostname if browser_hostname else get_webapp_url()
195196
workspace_id = get_workspace_id()
196197
return workspace_host, workspace_id
197198
return None, None

tests/utils/test_databricks_utils.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ def test_get_workspace_info_from_databricks_secrets():
104104
def test_get_workspace_info_from_dbutils():
105105
mock_dbutils = mock.MagicMock()
106106
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.browserHostName.return_value.get.return_value = ( # noqa
107+
"mlflow.databricks.com"
108+
)
109+
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.workspaceId.return_value.get.return_value = ( # noqa
110+
"1111"
111+
)
112+
with mock.patch("mlflow.utils.databricks_utils._get_dbutils", return_value=mock_dbutils):
113+
workspace_host, workspace_id = get_workspace_info_from_dbutils()
114+
assert workspace_host == "https://mlflow.databricks.com"
115+
assert workspace_id == "1111"
116+
117+
118+
def test_get_workspace_info_from_dbutils_no_browser_host_name():
119+
mock_dbutils = mock.MagicMock()
120+
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.browserHostName.return_value.get.return_value = ( # noqa
121+
None
122+
)
123+
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.apiUrl.return_value.get.return_value = ( # noqa
107124
"https://mlflow.databricks.com"
108125
)
109126
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.workspaceId.return_value.get.return_value = ( # noqa
@@ -121,7 +138,7 @@ def test_get_workspace_info_from_dbutils_old_runtimes():
121138
'{"tags": {"orgId" : "1111", "browserHostName": "mlflow.databricks.com"}}'
122139
)
123140
mock_dbutils.notebook.entry_point.getDbutils.return_value.notebook.return_value.getContext.return_value.browserHostName.return_value.get.return_value = ( # noqa
124-
"https://mlflow.databricks.com"
141+
"mlflow.databricks.com"
125142
)
126143
# Mock out workspace ID tag
127144
mock_workspace_id_tag_opt = mock.MagicMock()

0 commit comments

Comments
 (0)