-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathExport_Experiments.py
94 lines (67 loc) · 2.78 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Databricks notebook source
# MAGIC %md ## Export Experiments
# MAGIC
# MAGIC Export multiple experiments and all their runs.
# MAGIC
# MAGIC Widgets
# MAGIC * `1. Experiments` - comma delimited list of either experiment IDs or experiment names. `all` will export all experiments. Or filename (ending with .txt) with experiment names/IDs.
# MAGIC * `2. Output directory` - shared directory between source and destination workspaces.
# MAGIC * `3. Run start date` - Export runs after this UTC date (inclusive). Example: `2023-04-05`.
# MAGIC * `4. Export permissions` - export Databricks permissions.
# MAGIC * `5. Export deleted runs`
# MAGIC * `6. Notebook formats`
# MAGIC * `7. Use threads`
# COMMAND ----------
# MAGIC %run ./Common
# COMMAND ----------
dbutils.widgets.text("1. Experiments", "")
experiments = dbutils.widgets.get("1. Experiments")
dbutils.widgets.text("2. Output directory", "")
output_dir = dbutils.widgets.get("2. Output directory")
output_dir = output_dir.replace("dbfs:","/dbfs")
dbutils.widgets.text("3. Run start date", "")
run_start_date = dbutils.widgets.get("3. Run start date")
dbutils.widgets.dropdown("4. Export permissions","no",["yes","no"])
export_permissions = dbutils.widgets.get("4. Export permissions") == "yes"
dbutils.widgets.dropdown("5. Export deleted runs","no",["yes","no"])
export_deleted_runs = dbutils.widgets.get("5. Export deleted runs") == "yes"
notebook_formats = get_notebook_formats(6)
dbutils.widgets.dropdown("7. Use threads","False",["True","False"])
use_threads = dbutils.widgets.get("7. Use threads") == "True"
if run_start_date=="": run_start_date = None
print("experiments:", experiments)
print("output_dir:", output_dir)
print("run_start_date:", run_start_date)
print("export_permissions:", export_permissions)
print("export_deleted_runs:", export_deleted_runs)
print("notebook_formats:", notebook_formats)
print("use_threads:", use_threads)
# COMMAND ----------
assert_widget(experiments, "1. Experiments")
assert_widget(output_dir, "2. Output directory")
# COMMAND ----------
from mlflow_export_import.bulk.export_experiments import export_experiments
export_experiments(
experiments = experiments,
output_dir = output_dir,
run_start_time = run_start_date,
export_permissions = export_permissions,
export_deleted_runs = export_deleted_runs,
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