Skip to content

Commit 14e8e43

Browse files
authored
direct: Handle num_workers and workload_type fields for clusters as in TF (#3834)
## Changes Handle num_workers and workload_type fields for clusters as in TF ## Why To avoid differences in behaviour between 2 implementations 1. When `autoscale` is not set, `num_workers` should be sent even if it's zero 2. when `workload_type` is set, both `notebook` and `job` clients default to `true` unless overridden ## Tests Added an acceptance test
1 parent e7a3c07 commit 14e8e43

File tree

12 files changed

+161
-2
lines changed

12 files changed

+161
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
bundle:
2+
name: test-deploy-cluster-num-workers-absent
3+
4+
resources:
5+
clusters:
6+
# Expecting num_workers to be sent as zero
7+
cluster1:
8+
cluster_name: test-cluster-1
9+
spark_version: 13.3.x-scala2.12
10+
node_type_id: i3.xlarge
11+
spark_conf:
12+
"spark.executor.memory": "2g"
13+
14+
# Expecting num_workers to be sent as absent
15+
cluster2:
16+
cluster_name: test-cluster-2
17+
spark_version: 13.3.x-scala2.12
18+
node_type_id: i3.xlarge
19+
autoscale:
20+
min_workers: 2
21+
max_workers: 7
22+
spark_conf:
23+
"spark.executor.memory": "2g"

acceptance/bundle/resources/clusters/deploy/num_workers_absent/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
>>> errcode [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-deploy-cluster-num-workers-absent/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> print_requests.py //clusters/create
9+
{
10+
"method": "POST",
11+
"path": "/api/2.1/clusters/create",
12+
"body": {
13+
"autotermination_minutes": 60,
14+
"cluster_name": "test-cluster-1",
15+
"node_type_id": "[NODE_TYPE_ID]",
16+
"num_workers": 0,
17+
"spark_conf": {
18+
"spark.executor.memory": "2g"
19+
},
20+
"spark_version": "13.3.x-scala2.12"
21+
}
22+
}
23+
{
24+
"method": "POST",
25+
"path": "/api/2.1/clusters/create",
26+
"body": {
27+
"autoscale": {
28+
"max_workers": 7,
29+
"min_workers": 2
30+
},
31+
"autotermination_minutes": 60,
32+
"cluster_name": "test-cluster-2",
33+
"node_type_id": "[NODE_TYPE_ID]",
34+
"spark_conf": {
35+
"spark.executor.memory": "2g"
36+
},
37+
"spark_version": "13.3.x-scala2.12"
38+
}
39+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace errcode $CLI bundle deploy
2+
trace print_requests.py //clusters/create | jq -s 'sort_by(.body.cluster_name)[]'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Local = true
2+
Cloud = false
3+
RecordRequests = true
4+
5+
Ignore = [
6+
"databricks.yml",
7+
]
8+
9+
[[Repls]]
10+
Old = "[0-9]{4}-[0-9]{6}-[0-9a-z]{8}"
11+
New = "[CLUSTER-ID]"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
bundle:
2+
name: test-deploy-cluster-workload-type
3+
4+
resources:
5+
clusters:
6+
cluster1:
7+
cluster_name: test-cluster
8+
spark_version: 13.3.x-scala2.12
9+
node_type_id: i3.xlarge
10+
num_workers: 2
11+
workload_type:
12+
clients:
13+
jobs: false
14+
spark_conf:
15+
"spark.executor.memory": "2g"

acceptance/bundle/resources/clusters/deploy/workload_type/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
>>> errcode [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-deploy-cluster-workload-type/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> print_requests.py //clusters/create
9+
{
10+
"method": "POST",
11+
"path": "/api/2.1/clusters/create",
12+
"body": {
13+
"autotermination_minutes": 60,
14+
"cluster_name": "test-cluster",
15+
"node_type_id": "[NODE_TYPE_ID]",
16+
"num_workers": 2,
17+
"spark_conf": {
18+
"spark.executor.memory": "2g"
19+
},
20+
"spark_version": "13.3.x-scala2.12",
21+
"workload_type": {
22+
"clients": {
23+
"jobs": false,
24+
"notebooks": true
25+
}
26+
}
27+
}
28+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace errcode $CLI bundle deploy
2+
trace print_requests.py //clusters/create
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Local = true
2+
Cloud = false
3+
RecordRequests = true
4+
5+
Ignore = [
6+
"databricks.yml",
7+
]
8+
9+
[[Repls]]
10+
Old = "[0-9]{4}-[0-9]{6}-[0-9a-z]{8}"
11+
New = "[CLUSTER-ID]"

0 commit comments

Comments
 (0)