Skip to content

Commit 8f61fd5

Browse files
committed
Completing list_experiments. Adding restore_run and restore_experiment as Dataiku extensions to the python API (only available through the CLI in legacy MLflow ET)
1 parent 6d6e067 commit 8f61fd5

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

dataikuapi/dss/mlflow.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ def list_models(self, run_id):
2323
)
2424
return response.json()
2525

26-
def list_experiments(self):
26+
def list_experiments(self, view_type="ACTIVE_ONLY", max_results=1000):
2727
"""
2828
Returns the list of experiments in the DSS project for which MLflow integration
2929
is setup
3030
31+
:param view_type: ACTIVE_ONLY, DELETED_ONLY or ALL
32+
:type view_type: str
33+
:param max_results: max results count
34+
:type max_results: int
3135
:rtype: dict
3236
"""
3337
response = self.client._perform_http(
34-
"GET", "/api/2.0/mlflow/experiments/list",
38+
"GET", "/api/2.0/mlflow/experiments/list?view_type={view_type}&max_results={max_results}".format(view_type=view_type, max_results=max_results),
3539
headers={"x-dku-mlflow-project-key": self.project_key}
3640
)
3741
return response.json()
@@ -52,6 +56,34 @@ def rename_experiment(self, experiment_id, new_name):
5256
)
5357
return response.json()
5458

59+
def restore_experiment(self, experiment_id):
60+
"""
61+
Restores a deleted experiment
62+
63+
:param experiment_id: experiment id
64+
:type experiment_id: str
65+
"""
66+
response = self.client._perform_http(
67+
"POST", "/api/2.0/mlflow/experiments/restore",
68+
headers={"x-dku-mlflow-project-key": self.project_key},
69+
body={"experiment_id": experiment_id}
70+
)
71+
return response.json()
72+
73+
def restore_run(self, run_id):
74+
"""
75+
Restores a deleted run
76+
77+
:param run_id: run id
78+
:type run_id: str
79+
"""
80+
response = self.client._perform_http(
81+
"POST", "/api/2.0/mlflow/runs/restore",
82+
headers={"x-dku-mlflow-project-key": self.project_key},
83+
body={"run_id": run_id}
84+
)
85+
return response.json()
86+
5587
def garbage_collect(self):
5688
"""
5789
Permanently deletes the experiments and runs marked as "Deleted

0 commit comments

Comments
 (0)