Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
bundle:
name: test-bundle-$UNIQUE_NAME

# cluster_id makes OverrideCompute clear job_cluster_key, so the merged config
# has no value for it even though the YAML still declares it.

variables:
cluster_key:
default: shared
cluster:
type: complex
default:
spark_version: 13.3.x-scala2.12
num_workers: 1

resources:
jobs:
my_job:
job_clusters:
- job_cluster_key: shared
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 1
- job_cluster_key: other
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 2
tasks:
- task_key: main
job_cluster_key: shared
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- task_key: by_variable
job_cluster_key: ${var.cluster_key}
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- task_key: by_complex_variable
new_cluster: ${var.cluster}
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb

targets:
dev:
mode: development
cluster_id: 0101-000000-override
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false
GOOS.windows = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files...
Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Move the tasks back to job clusters remotely

=== Sync replaces the job_cluster_key the YAML already has and keeps the variables

>>> [CLI] bundle config-remote-sync -t dev --save
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
tasks[task_key='by_complex_variable'].existing_cluster_id: remove
tasks[task_key='by_complex_variable'].new_cluster: skip
tasks[task_key='by_variable'].existing_cluster_id: remove
tasks[task_key='by_variable'].job_cluster_key: replace
tasks[task_key='main'].existing_cluster_id: remove
tasks[task_key='main'].job_cluster_key: replace



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -28,5 +28,5 @@
tasks:
- task_key: main
- job_cluster_key: shared
+ job_cluster_key: other
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb

=== The override still clears job_cluster_key, so the next sync detects it again

>>> [CLI] bundle config-remote-sync -t dev
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
tasks[task_key='by_complex_variable'].existing_cluster_id: remove
tasks[task_key='by_complex_variable'].new_cluster: skip
tasks[task_key='by_variable'].existing_cluster_id: remove
tasks[task_key='by_variable'].job_cluster_key: replace
tasks[task_key='main'].existing_cluster_id: remove
tasks[task_key='main'].job_cluster_key: replace



>>> [CLI] bundle destroy --auto-approve -t dev
The following resources will be deleted:
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
envsubst < databricks.yml.tmpl > databricks.yml
cleanup() { trace $CLI bundle destroy --auto-approve -t dev; }
trap cleanup EXIT
$CLI bundle deploy -t dev
job_id="$(read_id.py my_job)"

title "Move the tasks back to job clusters remotely"
edit_resource.py jobs $job_id <<PYEDIT
for task in r["tasks"]:
task.pop("existing_cluster_id", None)
if task["task_key"] == "by_complex_variable":
task["new_cluster"] = {"spark_version": "13.3.x-scala2.12", "num_workers": 3}
else:
task["job_cluster_key"] = "other" if task["task_key"] == "main" else "shared"
PYEDIT

title "Sync replaces the job_cluster_key the YAML already has and keeps the variables"
cp databricks.yml databricks.yml.backup
trace $CLI bundle config-remote-sync -t dev --save
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup

title "The override still clears job_cluster_key, so the next sync detects it again"
trace $CLI bundle config-remote-sync -t dev
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore = [".databricks", "databricks.yml", "databricks.yml.backup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
bundle:
name: test-bundle-$UNIQUE_NAME

# cluster_id makes OverrideCompute clear job_cluster_key. The tasks inherit it through
# merge keys, from an anchor outside resources and from one inside them.

definitions:
outside: &outside
job_cluster_key: shared

resources:
jobs:
my_job:
job_clusters:
- job_cluster_key: shared
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 1
- job_cluster_key: other
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 2
tasks:
- <<: *outside
task_key: from_outside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- <<: &inside
job_cluster_key: shared
task_key: defines_inside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- <<: *inside
task_key: from_inside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb

targets:
dev:
mode: development
cluster_id: 0101-000000-override
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false
GOOS.windows = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files...
Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Move the tasks back to job clusters remotely

=== Sync adds job_cluster_key to the tasks that inherit it

>>> [CLI] bundle config-remote-sync -t dev --save
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
tasks[task_key='defines_inside'].existing_cluster_id: remove
tasks[task_key='defines_inside'].job_cluster_key: add
tasks[task_key='from_inside'].existing_cluster_id: remove
tasks[task_key='from_inside'].job_cluster_key: add
tasks[task_key='from_outside'].existing_cluster_id: remove
tasks[task_key='from_outside'].job_cluster_key: add



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -22,17 +22,20 @@
num_workers: 2
tasks:
- - <<: *outside
+ - !!merge <<: *outside
task_key: from_outside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- - <<: &inside
+ job_cluster_key: other
+ - !!merge <<: &inside
job_cluster_key: shared
task_key: defines_inside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
- - <<: *inside
+ job_cluster_key: other
+ - !!merge <<: *inside
task_key: from_inside
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb
+ job_cluster_key: other

targets:

>>> [CLI] bundle destroy --auto-approve -t dev
The following resources will be deleted:
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
envsubst < databricks.yml.tmpl > databricks.yml
cleanup() { trace $CLI bundle destroy --auto-approve -t dev; }
trap cleanup EXIT
$CLI bundle deploy -t dev
job_id="$(read_id.py my_job)"

title "Move the tasks back to job clusters remotely"
edit_resource.py jobs $job_id <<PYEDIT
for task in r["tasks"]:
task.pop("existing_cluster_id", None)
task["job_cluster_key"] = "other"
PYEDIT

title "Sync adds job_cluster_key to the tasks that inherit it"
cp databricks.yml databricks.yml.backup
trace $CLI bundle config-remote-sync -t dev --save
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore = [".databricks", "databricks.yml", "databricks.yml.backup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
bundle:
name: test-bundle-$UNIQUE_NAME

# max_concurrent_runs is declared in both blocks and the target's value wins, but it
# is anchored and aliased there, so replacing it would leave the alias dangling.

resources:
jobs:
my_job:
max_concurrent_runs: 1
tasks:
- task_key: main
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb

targets:
dev:
resources:
jobs:
my_job:
max_concurrent_runs: &runs 2
timeout_seconds: *runs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false
GOOS.windows = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev/files...
Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Change the field remotely

=== Sync leaves the anchored target value unapplied

>>> [CLI] bundle config-remote-sync -t dev --save
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
max_concurrent_runs: replace



>>> diff.py databricks.yml.backup databricks.yml

>>> [CLI] bundle validate -t dev -o json
{"max_concurrent_runs":2,"timeout_seconds":2}

>>> [CLI] bundle destroy --auto-approve -t dev
The following resources will be deleted:
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/dev

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
envsubst < databricks.yml.tmpl > databricks.yml
cleanup() { trace $CLI bundle destroy --auto-approve -t dev; }
trap cleanup EXIT
$CLI bundle deploy -t dev
job_id="$(read_id.py my_job)"

title "Change the field remotely"
edit_resource.py jobs $job_id <<PYEDIT
r["max_concurrent_runs"] = 10
PYEDIT

title "Sync leaves the anchored target value unapplied"
cp databricks.yml databricks.yml.backup
trace $CLI bundle config-remote-sync -t dev --save
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup
trace $CLI bundle validate -t dev -o json | jq -c ".resources.jobs.my_job | {max_concurrent_runs, timeout_seconds}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
bundle:
name: test-bundle-$UNIQUE_NAME

# The task is split between both blocks and each declares job_cluster_key.
# cluster_id makes OverrideCompute clear it, so the merged leaf has no location;
# the target's copy wins the merge, so that is the one to replace.

resources:
jobs:
my_job:
job_clusters:
- job_cluster_key: shared
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 1
- job_cluster_key: other
new_cluster:
spark_version: 13.3.x-scala2.12
num_workers: 2
tasks:
- task_key: main
job_cluster_key: shared
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/nb

targets:
dev:
mode: development
cluster_id: 0101-000000-override
resources:
jobs:
my_job:
tasks:
- task_key: main
job_cluster_key: shared
max_retries: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false
GOOS.windows = false
EnvMatrix.DMS = ["", "true"]
Loading
Loading