forked from mlflow/mlflow-export-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Export_Experiments.py
75 lines (53 loc) · 2.08 KB
/
Export_Experiments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Databricks notebook source
# MAGIC %md ## Export Experiments
# MAGIC
# MAGIC Export multiple experiments and all their runs.
# MAGIC
# MAGIC Widgets
# MAGIC * Experiments - comma delimited list of either experiment ID or experiment name. `all` will export all experiments.
# MAGIC * Output base directory - cloud mounted shared directory between source and destination workspaces.
# MAGIC * Notebook formats
# MAGIC * Use threads
# COMMAND ----------
# MAGIC %run ./Common
# COMMAND ----------
dbutils.widgets.text("1. Experiments", "")
experiments = dbutils.widgets.get("1. Experiments")
dbutils.widgets.text("2. Output base directory", "")
output_dir = dbutils.widgets.get("2. Output base directory")
output_dir = output_dir.replace("dbfs:","/dbfs")
all_formats = [ "SOURCE", "DBC", "HTML", "JUPYTER" ]
dbutils.widgets.multiselect("3. Notebook formats",all_formats[0],all_formats)
notebook_formats = dbutils.widgets.get("3. Notebook formats")
dbutils.widgets.dropdown("4. Use threads","False",["True","False"])
use_threads = dbutils.widgets.get("4. Use threads") == "True"
print("experiments:",experiments)
print("output_dir:",output_dir)
print("notebook_formats:",notebook_formats)
print("use_threads:",use_threads)
# COMMAND ----------
assert_widget(experiments, "1. Experiments")
assert_widget(output_dir, "2. Output base directory")
# COMMAND ----------
import mlflow
from mlflow_export_import.bulk.export_experiments import export_experiments
export_experiments(mlflow.client.MlflowClient(),
experiments=experiments,
output_dir=output_dir,
notebook_formats=notebook_formats,
use_threads=use_threads)
# COMMAND ----------
# MAGIC %md ### Display exported files
# COMMAND ----------
import os
output_dir = output_dir.replace("dbfs:","/dbfs")
os.environ['OUTPUT_DIR'] = output_dir
output_dir
# COMMAND ----------
# MAGIC %sh
# MAGIC echo "OUTPUT_DIR: $OUTPUT_DIR" ; echo
# MAGIC ls $OUTPUT_DIR
# COMMAND ----------
# MAGIC %sh cat $OUTPUT_DIR/experiments.json
# COMMAND ----------
# MAGIC %sh ls -lR $OUTPUT_DIR