generated from databricks-industry-solutions/industry-solutions-blueprints
-
Notifications
You must be signed in to change notification settings - Fork 7
/
RUNME.py
571 lines (554 loc) · 21.8 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# 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/dbacademy@v1.0.13 git+https://github.com/databricks-industry-solutions/notebook-solution-companion@safe-print-html --quiet --disable-pip-version-check
# COMMAND ----------
from solacc.companion import NotebookSolutionCompanion
# COMMAND ----------
# MAGIC %md You need to provide your docker credential before running this accelerator. [Sign up](https://hub.docker.com/signup) for a Docker account if you do not already have one. Here we demonstrate using the [Databricks Secret Scope](https://docs.databricks.com/security/secrets/secret-scopes.html) for credential management.
# MAGIC
# MAGIC Copy the block of code below, replace the name the secret scope and fill in the credentials and execute the block. After executing the code, The accelerator notebook will be able to access the credentials it needs.
# MAGIC
# MAGIC ```
# MAGIC client = NotebookSolutionCompanion().client
# MAGIC client.execute_post_json(f"{client.endpoint}/api/2.0/secrets/scopes/create", {"scope": "solution-accelerator-cicd"})
# MAGIC
# MAGIC client.execute_post_json(f"{client.endpoint}/api/2.0/secrets/put", {
# MAGIC "scope": "solution-accelerator-cicd",
# MAGIC "key": "docker_username",
# MAGIC "string_value": "____"
# MAGIC })
# MAGIC client.execute_post_json(f"{client.endpoint}/api/2.0/secrets/put", {
# MAGIC "scope": "solution-accelerator-cicd",
# MAGIC "key": "docker_password",
# MAGIC "string_value": "____"
# MAGIC })
# MAGIC
# MAGIC ```
# COMMAND ----------
from dbacademy.dbgems import get_username
docker_username = dbutils.secrets.get("solution-accelerator-cicd", "docker_username") # this secret scope is set up to enable testing only in Databricks' internal environment; please set up secret scope with your own credential
docker_password = dbutils.secrets.get("solution-accelerator-cicd", "docker_password") # this secret scope is set up to enable testing only in Databricks' internal environment; please set up secret scope with your own credential
job_json = {
"timeout_seconds": 0,
"tags":{
"usage": "solacc_testing",
"group": "HLS",
"accelerator": "glow-solution-accelerator"
},
"email_notifications": {},
"max_concurrent_runs": 1,
"tasks": [
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/data/download_1000G"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "download_1000G",
"description": ""
},
{
"job_cluster_key": "single_node",
"notebook_task": {
"notebook_path": f"/etl/1_simulate_covariates_phenotypes_offset"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "simulate_covariates_phenotypes_offset",
"depends_on": [
{
"task_key": "download_1000G"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/2_simulate_delta_pvcf"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "simulate_delta_pvcf",
"depends_on": [
{
"task_key": "download_1000G"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/3_delta_to_vcf"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "delta_to_vcf",
"depends_on": [
{
"task_key": "simulate_delta_pvcf"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/pipe-transformer-plink"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "pipe_transformer_plink",
"depends_on": [
{
"task_key": "delta_to_vcf"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/10_liftOver"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "liftOver",
"depends_on": [
{
"task_key": "delta_to_vcf"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/parallel_bcftools_filter"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "parallel_bcftools_filter",
"depends_on": [
{
"task_key": "liftOver"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/0_ingest_vcf2delta"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "ingest_vcf2delta",
"depends_on": [
{
"task_key": "delta_to_vcf"
}
]
},
{
"job_cluster_key": "hail",
"libraries": [
{
"pypi": {
"package": "glow.py==1.2.1"
}
},
{
"maven": {
"coordinates": "io.projectglow:glow-spark3_2.12:1.2.1"
}
}
],
"notebook_task": {
"notebook_path": f"/etl/4_vcf_to_hail_mt"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "ingest_to_hail",
"depends_on": [
{
"task_key": "delta_to_vcf"
}
]
},
{
"job_cluster_key": "hail_to_glow",
"libraries": [
{
"pypi": {
"package": "glow.py==1.2.1"
}
},
{
"maven": {
"coordinates": "io.projectglow:glow-spark3_2.12:1.2.1"
}
}
],
"notebook_task": {
"notebook_path": f"/etl/5_hail_mt_to_glow"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "export_hail_to_glow",
"depends_on": [
{
"task_key": "ingest_to_hail"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/1_quality_control"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "quality_control",
"depends_on": [
{
"task_key": "ingest_vcf2delta"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/6_explode_variant_dataframe"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "explode_variants_for_querying",
"depends_on": [
{
"task_key": "quality_control"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/7_etl_gff_annotations"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "generate_gff3_annotations"
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/8_create_database_for_querying"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "create_database_for_querying",
"depends_on": [
{
"task_key": "generate_gff3_annotations"
},
{
"task_key": "explode_variants_for_querying"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/etl/9_query_variant_db"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "query_variant_database",
"depends_on": [
{
"task_key": "create_database_for_querying"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/2_quantitative_glowgr"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "glowgr_quantitative",
"depends_on": [
{
"task_key": "simulate_covariates_phenotypes_offset"
},
{
"task_key": "quality_control"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/3_linear_gwas_glow",
"base_parameters": {
"user": get_username() # to pass user email into R
}
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "glow_linear_gwas",
"depends_on": [
{
"task_key": "glowgr_quantitative"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/4_binary_glowgr"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "glowgr_binary",
"depends_on": [
{
"task_key": "glow_linear_gwas"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/5_logistic_gwas_glow"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "glow_logistic_gwas",
"depends_on": [
{
"task_key": "glowgr_binary"
}
]
},
{
"job_cluster_key": "hail",
"libraries": [
{
"pypi": {
"package": "glow.py==1.2.1"
}
},
{
"maven": {
"coordinates": "io.projectglow:glow-spark3_2.12:1.2.1"
}
}
],
"notebook_task": {
"notebook_path": f"/tertiary/6_hail_linreg_gwas"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "hail_linear_gwas",
"depends_on": [
{
"task_key": "simulate_covariates_phenotypes_offset"
},
{
"task_key": "ingest_to_hail"
}
]
},
{
"job_cluster_key": "hail",
"libraries": [
{
"maven": {
"coordinates": "io.projectglow:glow-spark3_2.12:1.2.1"
}
},
{
"pypi": {
"package": "glow.py==1.2.1"
}
}
],
"notebook_task": {
"notebook_path": f"/tertiary/7_hail_logistic_gwas"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "hail_logistic_gwas",
"depends_on": [
{
"task_key": "simulate_covariates_phenotypes_offset"
},
{
"task_key": "ingest_to_hail"
}
]
},
{
"job_cluster_key": "hail",
"libraries": [
{
"pypi": {
"package": "glow.py==1.2.1"
}
},
{
"maven": {
"coordinates": "io.projectglow:glow-spark3_2.12:1.2.1"
}
}
],
"notebook_task": {
"notebook_path": f"/tertiary/9_compare_hail_to_glow"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "compare_hail_to_glow",
"depends_on": [
{
"task_key": "glow_logistic_gwas"
},
{
"task_key": "hail_linear_gwas"
},
{
"task_key": "hail_logistic_gwas"
}
]
},
{
"job_cluster_key": "glow_integration_test",
"notebook_task": {
"notebook_path": f"/tertiary/8_pipeline_runs_comparison"
},
"timeout_seconds": 0,
"email_notifications": {},
"task_key": "pipeline_benchmarks",
"depends_on": [
{
"task_key": "compare_hail_to_glow"
}
]
}
],
"job_clusters": [
{
"job_cluster_key": "glow_integration_test",
"new_cluster": {
"cluster_name": "",
"spark_version": "10.4.x-scala2.12",
"spark_conf": {
"spark.databricks.delta.preview.enabled": "true",
"spark.databricks.delta.formatCheck.enabled": "false"
},
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS4_v2", "GCP": "n1-highmem-4"},
"enable_elastic_disk": "true",
"docker_image": {
"url": "projectglow/databricks-glow:1.2.1",
"basic_auth": {
"username": docker_username,
"password": docker_password
}
},
"data_security_mode": "NONE",
"num_workers": 2
}
},
{
"job_cluster_key": "single_node",
"new_cluster": {
"cluster_name": "",
"spark_version": "10.4.x-scala2.12",
"spark_conf": {
"spark.databricks.delta.preview.enabled": "true",
"spark.databricks.delta.formatCheck.enabled": "false"
},
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS4_v2", "GCP": "n1-highmem-4"},
"enable_elastic_disk": "true",
"docker_image": {
"url": "projectglow/databricks-glow:1.2.1",
"basic_auth": {
"username": docker_username,
"password": docker_password
}
},
"data_security_mode": "NONE",
"num_workers": 0
}
},
{
"job_cluster_key": "hail",
"new_cluster": {
"cluster_name": "",
"spark_version": "9.1.x-scala2.12",
"spark_conf": {
"spark.databricks.delta.preview.enabled": "true",
"spark.databricks.delta.formatCheck.enabled": "false"
},
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS4_v2", "GCP": "n1-highmem-4"},
"enable_elastic_disk": "true",
"docker_image": {
"url": "projectglow/databricks-hail:0.2.85",
"basic_auth": {
"username": docker_username,
"password": docker_password
}
},
"data_security_mode": "NONE",
"num_workers": 2
}
},
{
"job_cluster_key": "hail_to_glow",
"new_cluster": {
"cluster_name": "",
"spark_version": "9.1.x-scala2.12",
"spark_conf": {
"spark.databricks.delta.preview.enabled": "true",
"spark.databricks.delta.formatCheck.enabled": "false"
},
"node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS4_v2", "GCP": "n1-highmem-4"},
"enable_elastic_disk": "true",
"docker_image": {
"url": "projectglow/databricks-hail:0.2.85",
"basic_auth": {
"username": docker_username,
"password": docker_password
}
},
"data_security_mode": "NONE",
"num_workers": 2
}
}
]
}
# COMMAND ----------
dbutils.widgets.dropdown("run_job", "False", ["True", "False"])
run_job = dbutils.widgets.get("run_job") == "True"
NotebookSolutionCompanion().deploy_compute(job_json, run_job=run_job)
# COMMAND ----------
# COMMAND ----------