Diff of /RUNME.py [000000] .. [938e03]

Switch to unified view

a b/RUNME.py
1
# Databricks notebook source
2
# 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! 
3
# MAGIC 🎉
4
# MAGIC 
5
# MAGIC **Steps**
6
# 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. 
7
# MAGIC 
8
# 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. 
9
# MAGIC 
10
# MAGIC     2a. **Run the Workflow**: Navigate to the Workflow link and hit the `Run Now` 💥. 
11
# MAGIC   
12
# MAGIC     2b. **Run the notebooks interactively**: Attach the notebook with the cluster(s) created and execute as described in the `job_json['tasks']` below.
13
# MAGIC 
14
# MAGIC **Prerequisites** 
15
# MAGIC 1. You need to have cluster creation permissions in this workspace.
16
# MAGIC 
17
# 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. 
18
# MAGIC 
19
# MAGIC **Notes**
20
# 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.
21
# MAGIC 
22
# 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. 
23
24
# COMMAND ----------
25
26
# DBTITLE 0,Install util packages
27
# 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
28
29
# COMMAND ----------
30
31
from solacc.companion import NotebookSolutionCompanion
32
33
# COMMAND ----------
34
35
cluster_json = {
36
    "num_workers": 8,
37
    "cluster_name": "jsl_mrf_cluster",
38
    "spark_version": "9.1.x-cpu-ml-scala2.12", # This needs to match JSL version in partner connect
39
    "spark_conf": {
40
        "spark.serializer": "org.apache.spark.serializer.KryoSerializer",
41
        "spark.kryoserializer.buffer.max": "2000M",
42
        "spark.databricks.delta.formatCheck.enabled": "false"
43
    },
44
    "node_type_id": {"AWS": "i3.xlarge", "MSA": "Standard_DS3_v2", "GCP": "n1-highmem-4"}, # different from standard API; this is multi-cloud friendly
45
    "autotermination_minutes": 120
46
}
47
48
# COMMAND ----------
49
50
nsc = NotebookSolutionCompanion()
51
cluster_id = nsc.create_or_update_cluster_by_name(nsc.customize_cluster_json(cluster_json))
52
53
# COMMAND ----------
54
55
task_json = {'tasks': [{
56
    'task_key': 'setup_cluster',
57
    'depends_on': [],
58
    'existing_cluster_id': cluster_id,
59
    "notebook_task": {
60
        "notebook_path": "/Shared/John Snow Labs/Install JohnSnowLabs NLP",
61
        "source": "WORKSPACE"
62
        },
63
    'timeout_seconds': 86400}]
64
            }
65
nsc.submit_run(task_json)
66
67
# COMMAND ----------
68
69
job_json = {
70
        "timeout_seconds": 7200,
71
        "max_concurrent_runs": 1,
72
        "tags": {
73
            "usage": "solacc_testing",
74
            "group": "HLS"
75
        },
76
        "tasks": [
77
            {
78
                "existing_cluster_id": cluster_id,
79
                "notebook_task": {
80
                    "notebook_path": "01-Insurance_Risk_Factors"
81
                },
82
                "task_key": "jsl_mrf_01",
83
                "description": ""
84
            },
85
            # {
86
            #     "existing_cluster_id": cluster_id,
87
            #     "notebook_task": {
88
            #         "notebook_path": "01-jsl-entity-extraction"
89
            #     },
90
            #     "task_key": "jsl_kg_01",
91
            #     "depends_on": [
92
            #         {
93
            #             "task_key": "jsl_kg_00"
94
            #         }
95
            #     ],
96
            #     "description": ""
97
            # },
98
            # {
99
            #     "existing_cluster_id": cluster_id,
100
            #     "libraries": [],
101
            #     "notebook_task": {
102
            #         "notebook_path": "02-knowledge-graph"
103
            #     },
104
            #     "task_key": "jsl_kg_02",
105
            #     "description": "",
106
            #     "depends_on": [
107
            #         {
108
            #             "task_key": "jsl_kg_01"
109
            #         }
110
            #     ]
111
            # }
112
        ]
113
    }
114
115
# COMMAND ----------
116
117
dbutils.widgets.dropdown("run_job", "False", ["True", "False"])
118
run_job = dbutils.widgets.get("run_job") == "True"
119
nsc.deploy_compute(job_json, run_job=run_job, wait=3600)
120
121
# COMMAND ----------
122
123
124
125
# COMMAND ----------
126
127