Skip to content

Commit bb2ac4d

Browse files
author
Valentin Thorey
authored
Merge pull request #200 from dataiku/feature/sc-77250-reload-mlflow-artifact-registry
Give MLflowHandle the ability to reload artifact_repository_registry
2 parents 79b0f4c + eb10699 commit bb2ac4d

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

dataikuapi/dss/project.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import time, warnings, sys, os.path as osp
2+
3+
from ..dss_plugin_mlflow import MLflowHandle
4+
25
from .dataset import DSSDataset, DSSDatasetListItem, DSSManagedDatasetCreationHelper
36
from .modelcomparison import DSSModelComparison
47
from .jupyternotebook import DSSJupyterNotebook, DSSJupyterNotebookListItem
@@ -1581,7 +1584,7 @@ def list_hive_tables(self, hive_database):
15811584
"""
15821585
connection_name = "@virtual(hive-jdbc):" + hive_database
15831586
ret = self.client._perform_json("GET", "/projects/%s/datasets/tables-import/actions/list-tables" % (self.project_key),
1584-
params = {"connectionName": connection_name} )
1587+
params={"connectionName": connection_name} )
15851588

15861589
def to_schema_table_pair(x):
15871590
return {"schema":x.get("databaseName", None), "table":x["table"]}
@@ -1590,14 +1593,21 @@ def to_schema_table_pair(x):
15901593
########################################################
15911594
# App designer
15921595
########################################################
1593-
15941596
def get_app_manifest(self):
15951597
raw_data = self.client._perform_json("GET", "/projects/%s/app-manifest" % self.project_key)
15961598
return DSSAppManifest(self.client, raw_data, self.project_key)
15971599

1598-
########################################################
15991600
# MLflow experiment tracking
16001601
########################################################
1602+
def setup_mlflow(self, managed_folder="mlflow_artifacts", host=None):
1603+
"""
1604+
Setup the dss-plugin for MLflow
1605+
1606+
:param str managed_folder: managed folder where artifacts are stored
1607+
:param str host: setup a custom host if the backend used is not DSS
1608+
"""
1609+
return MLflowHandle(client=self.client, project_key=self.project_key, managed_folder=managed_folder, host=host)
1610+
16011611
def clean_experiment_tracking_db(self):
16021612
"""
16031613
Cleans the experiments, runs, params, metrics, tags, etc. for this project

dataikuapi/dss_plugin_mlflow/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def __init__(self, client, project_key, managed_folder="mlflow_artifacts", host=
3737
)
3838
sys.path.insert(0, self.tempdir)
3939

40+
# Reload the artifact_repository_registry in case MLflow was imported beforehand
41+
if sys.version_info > (3, 4):
42+
from importlib import reload
43+
import mlflow
44+
reload(mlflow.store.artifact.artifact_repository_registry)
45+
4046
# Setup authentication
4147
if client._session.auth is not None:
4248
self.mlflow_env.update({

dataikuapi/dssclient.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from requests.auth import HTTPBasicAuth
66

77
from dataikuapi.dss.notebook import DSSNotebook
8-
from .dss_plugin_mlflow import MLflowHandle
98
from .dss.future import DSSFuture
109
from .dss.projectfolder import DSSProjectFolder
1110
from .dss.project import DSSProject
@@ -1088,19 +1087,6 @@ def get_object_discussions(self, project_key, object_type, object_id):
10881087
"""
10891088
return DSSObjectDiscussions(self, project_key, object_type, object_id)
10901089

1091-
########################################################
1092-
# MLflow
1093-
########################################################
1094-
def setup_mlflow(self, project_key, managed_folder="mlflow_artifacts", host=None):
1095-
"""
1096-
Setup the dss-plugin for MLflow
1097-
1098-
:param str project_key: identifier of the project to access
1099-
:param str managed_folder: managed folder where artifacts are stored
1100-
:param str host: setup a custom host if the backend used is not DSS
1101-
"""
1102-
return MLflowHandle(client=self, project_key=project_key, managed_folder=managed_folder, host=host)
1103-
11041090

11051091
class TemporaryImportHandle(object):
11061092
def __init__(self, client, import_id):

0 commit comments

Comments
 (0)