Skip to content

Commit 44df3b9

Browse files
Demonstrate how to use a development cluster (#37)
Note: this requires databricks/cli#1698. --------- Co-authored-by: Andrew Nester <andrew.nester.dev@gmail.com>
1 parent 0c77b21 commit 44df3b9

4 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Development cluster
2+
3+
This example demonstrates how to define and use a development (all-purpose) cluster in a Databricks Asset Bundle.
4+
5+
This bundle defines an `example_job` which is run on a job cluster in production mode.
6+
7+
For the development mode (default `dev` target) the job is overriden to use a development cluster which is provisioned
8+
as part of the bundle deployment as well.
9+
10+
For more information, please refer to the [documentation](https://docs.databricks.com/en/dev-tools/bundles/settings.html#clusters).
11+
12+
## Prerequisites
13+
14+
* Databricks CLI v0.229.0 or above
15+
16+
## Usage
17+
18+
Update the `host` field under `workspace` in `databricks.yml` to the Databricks workspace you wish to deploy to.
19+
20+
Run `databricks bundle deploy` to deploy the job. It's deployed to `dev` target with a defined `development_cluster` cluster.
21+
22+
Run `databricks bundle deploy -t prod` to deploy the job to prod target. It's deployed with a job cluster instead of development one.
23+
24+
Run `databricks bundle run example_job` to run the job.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
bundle:
2+
name: development_cluster
3+
4+
include:
5+
- resources/*.yml
6+
7+
workspace:
8+
host: https://e2-dogfood.staging.cloud.databricks.com
9+
10+
targets:
11+
dev:
12+
mode: development
13+
default: true
14+
15+
# By configuring this field for the "dev" target, all jobs in this bundle
16+
# are overridden to use the all-purpose cluster defined below.
17+
#
18+
# This can increase the speed of development when iterating on code and job definitions,
19+
# as you don't have to wait for job clusters to start for every job run.
20+
#
21+
# Note: make sure that the cluster configuration below matches the job cluster
22+
# definition that will be used when deploying the other targets.
23+
cluster_id: ${resources.clusters.development_cluster.id}
24+
25+
resources:
26+
clusters:
27+
development_cluster:
28+
cluster_name: Development cluster
29+
spark_version: 15.4.x-scala2.12
30+
node_type_id: i3.xlarge
31+
num_workers: 0
32+
autotermination_minutes: 30
33+
spark_conf:
34+
"spark.databricks.cluster.profile": "singleNode"
35+
"spark.master": "local[*, 4]"
36+
custom_tags:
37+
"ResourceClass": "SingleNode"
38+
39+
prod: {
40+
# No overrides
41+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resources:
2+
jobs:
3+
example_job:
4+
name: "Example job to demonstrate using an interactive cluster for development"
5+
6+
tasks:
7+
- task_key: notebook
8+
job_cluster_key: cluster
9+
notebook_task:
10+
notebook_path: ../src/hello.py
11+
12+
job_clusters:
13+
- job_cluster_key: cluster
14+
new_cluster:
15+
spark_version: 15.4.x-scala2.12
16+
node_type_id: i3.xlarge
17+
num_workers: 0
18+
spark_conf:
19+
"spark.databricks.cluster.profile": "singleNode"
20+
"spark.master": "local[*, 4]"
21+
custom_tags:
22+
"ResourceClass": "SingleNode"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Databricks notebook source
2+
3+
print("Hello, World!")

0 commit comments

Comments
 (0)