forked from hengrumay/digital-pathology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RUNME.py
249 lines (235 loc) · 9.24 KB
/
RUNME.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# Databricks notebook source
# MAGIC %md This notebook sets up the companion cluster(s) to run the solution accelerator. It also creates the Workflow to illustrate the order of execution. Happy exploring!
# MAGIC 🎉
# MAGIC
# MAGIC **Steps**
# MAGIC 1. Simply attach this notebook to a cluster and hit Run-All for this notebook. A multi-step job and the clusters used in the job will be created for you and hyperlinks are printed on the last block of the notebook.
# MAGIC
# MAGIC 2. Run the accelerator notebooks: Feel free to explore the multi-step job page and **run the Workflow**, or **run the notebooks interactively** with the cluster to see how this solution accelerator executes.
# MAGIC
# MAGIC 2a. **Run the Workflow**: Navigate to the Workflow link and hit the `Run Now` 💥.
# MAGIC
# MAGIC 2b. **Run the notebooks interactively**: Attach the notebook with the cluster(s) created and execute as described in the `job_json['tasks']` below.
# MAGIC
# MAGIC **Prerequisites**
# MAGIC 1. You need to have cluster creation permissions in this workspace.
# MAGIC
# MAGIC 2. In case the environment has cluster-policies that interfere with automated deployment, you may need to manually create the cluster in accordance with the workspace cluster policy. The `job_json` definition below still provides valuable information about the configuration these series of notebooks should run with.
# MAGIC
# MAGIC **Notes**
# MAGIC 1. The pipelines, workflows and clusters created in this script are not user-specific. Keep in mind that rerunning this script again after modification resets them for other users too.
# MAGIC
# MAGIC 2. If the job execution fails, please confirm that you have set up other environment dependencies as specified in the accelerator notebooks. Accelerators may require the user to set up additional cloud infra or secrets to manage credentials.
# COMMAND ----------
# DBTITLE 0,Install util packages
# MAGIC %pip install git+https://github.com/databricks-academy/[email protected] git+https://github.com/databricks-industry-solutions/notebook-solution-companion@safe-print-html --quiet --disable-pip-version-check
# MAGIC dbutils.library.restartPython()
# COMMAND ----------
from solacc.companion import NotebookSolutionCompanion
nsc = NotebookSolutionCompanion()
# COMMAND ----------
job_json = {
"timeout_seconds": 28800,
"max_concurrent_runs": 1,
"tags": {
"usage": "solacc_testing",
"group": "HLS"
},
"tasks": [
{
"task_key": "Pathology_00",
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "00-create-annotation-deltalake",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_01",
"depends_on": [
{
"task_key": "Pathology_00"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "01-README",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_02",
"depends_on": [
{
"task_key": "Pathology_01"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "02-patch-generation",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_03",
"depends_on": [
{
"task_key": "Pathology_02"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "03-feature-extraction",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_04",
"depends_on": [
{
"task_key": "Pathology_03"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "04-unsupervised-learning",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_05",
"depends_on": [
{
"task_key": "Pathology_02"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "05-training",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_gpu_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "Pathology_06",
"depends_on": [
{
"task_key": "Pathology_05"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "06-metastasis-heatmap",
"source": "WORKSPACE"
},
"job_cluster_key": "pathology_cluster_w_init",
"libraries": [
{
"pypi": {
"package": "openslide-python"
}
}
],
"timeout_seconds": 0,
"email_notifications": {}
}
],
"job_clusters": [
{
"job_cluster_key": "pathology_cluster",
"new_cluster": {
"spark_version": "12.2.x-cpu-ml-scala2.12",
"num_workers": 2,
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS3_v2", "GCP": "n1-highmem-4"}
}
},
{
"job_cluster_key": "pathology_cluster_w_init",
"new_cluster": {
"spark_version": "12.2.x-cpu-ml-scala2.12",
"num_workers": 2,
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS3_v2", "GCP": "n1-highmem-4"},
"init_scripts": [
{
"workspace": {
"destination": f"{nsc.solacc_path}/openslide-tools.sh"
}
}
]
}
},
{
"job_cluster_key": "pathology_gpu_cluster_w_init",
"new_cluster": {
"spark_version": "12.2.x-gpu-ml-scala2.12",
"num_workers": 1,
"node_type_id": {"AWS": "g4dn.4xlarge", "MSA": "Standard_NC6s_v3", "GCP": "a2-highgpu-1g"},
"init_scripts": [
{
"workspace": {
"destination": f"{nsc.solacc_path}/openslide-tools.sh"
}
}
]
}
}
]
}
# COMMAND ----------
dbutils.widgets.dropdown("run_job", "False", ["True", "False"])
run_job = dbutils.widgets.get("run_job") == "True"
nsc.deploy_compute(job_json, run_job=run_job)
# COMMAND ----------
# COMMAND ----------