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

resources:
jobs:
my_job:
name: test-job-$UNIQUE_NAME
job_clusters:
- job_cluster_key: shared
new_cluster:
spark_version: $DEFAULT_SPARK_VERSION
node_type_id: $NODE_TYPE_ID
custom_tags: # Keep this comment when adding tags.
spark_env_vars: null # Keep the environment comment.
init_scripts: ~
autoscale: ~ # Keep the autoscale comment.
- job_cluster_key: nested
new_cluster: null # Keep the cluster comment through both tag additions.
tasks:
- task_key: main
job_cluster_key: shared
notebook_task:
notebook_path: /Users/{{workspace_user_name}}/notebook

targets:
default:
resources:
jobs:
my_job:
job_clusters:
- job_cluster_key: shared
new_cluster:
custom_tags:
existing: preserved
spark_env_vars:
EXISTING: preserved
autoscale:
min_workers: 1
- job_cluster_key: nested
new_cluster:
spark_version: $DEFAULT_SPARK_VERSION
node_type_id: $NODE_TYPE_ID
num_workers: 1
custom_tags:
existing: preserved
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cloud = false
GOOS.windows = false
EnvMatrix.DMS = ["", "true"]
59 changes: 59 additions & 0 deletions acceptance/bundle/config-remote-sync/null_parent/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files...
Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

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

Resource: resources.jobs.my_job
job_clusters[job_cluster_key='nested'].new_cluster.custom_tags['123']: add
job_clusters[job_cluster_key='nested'].new_cluster.custom_tags['team']: add
job_clusters[job_cluster_key='shared'].new_cluster.autoscale.max_workers: add
job_clusters[job_cluster_key='shared'].new_cluster.custom_tags['123']: add
job_clusters[job_cluster_key='shared'].new_cluster.custom_tags['team']: add
job_clusters[job_cluster_key='shared'].new_cluster.init_scripts: replace
job_clusters[job_cluster_key='shared'].new_cluster.spark_env_vars['ENV']: add



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -12,9 +12,18 @@
node_type_id: [NODE_TYPE_ID]
custom_tags: # Keep this comment when adding tags.
- spark_env_vars: null # Keep the environment comment.
- init_scripts: ~
- autoscale: ~ # Keep the autoscale comment.
+ "123": numeric key
+ team: analytics
+ spark_env_vars: # Keep the environment comment.
+ ENV: dev
+ init_scripts:
+ - workspace:
+ destination: /Workspace/init.sh
+ autoscale: # Keep the autoscale comment.
+ max_workers: 2
- job_cluster_key: nested
- new_cluster: null # Keep the cluster comment through both tag additions.
+ new_cluster: # Keep the cluster comment through both tag additions.
+ custom_tags:
+ "123": numeric key
+ team: analytics
tasks:
- task_key: main

>>> [CLI] bundle config-remote-sync --save
No changes detected.


>>> [CLI] bundle destroy --auto-approve
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]/default

Destroy: 1 deleted
27 changes: 27 additions & 0 deletions acceptance/bundle/config-remote-sync/null_parent/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

trace $CLI bundle deploy
job_id=$(read_id.py my_job)

# Target overrides supply existing keys; new keys route to the null parents in the base config.
edit_resource.py jobs "$job_id" <<'EOF'
for jc in r["job_clusters"]:
cluster = jc["new_cluster"]
cluster["custom_tags"].update({"team": "analytics", "123": "numeric key"})
if jc["job_cluster_key"] == "shared":
cluster["spark_env_vars"]["ENV"] = "dev"
cluster["init_scripts"] = [{"workspace": {"destination": "/Workspace/init.sh"}}]
cluster["autoscale"]["max_workers"] = 2
EOF

cp databricks.yml databricks.yml.backup
trace $CLI bundle config-remote-sync --save
trace diff.py databricks.yml.backup databricks.yml
rm databricks.yml.backup

trace $CLI bundle config-remote-sync --save
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
Expand Up @@ -7,6 +7,21 @@ variables:
default:
spark.speculation: "true"

init_scripts:
type: complex
default:
- workspace:
destination: /Workspace/init.sh
new_cluster:
type: complex
default:
spark_version: $DEFAULT_SPARK_VERSION
node_type_id: $NODE_TYPE_ID
num_workers: 1
custom_tags:
changed: original
removed: original

targets:
default:
mode: development
Expand All @@ -22,6 +37,9 @@ resources:
node_type_id: $NODE_TYPE_ID
num_workers: 1
spark_conf: ${var.spark_conf}
init_scripts: ${var.init_scripts}
- job_cluster_key: variable_cluster
new_cluster: ${var.new_cluster}
tasks:
- task_key: main
job_cluster_key: shared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Inject a spark_conf key under a field defined as a complex variable
spark_conf is set to a variable reference, so a remotely-added key cannot be
written into that scalar node; the change is skipped while unrelated edits still sync.
=== Edit fields under complex variables

=== Detect and save all changes
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
job_clusters[job_cluster_key='shared'].new_cluster.init_scripts[0].workspace.destination: skip
job_clusters[job_cluster_key='shared'].new_cluster.spark_conf['spark.executor.memory']: skip
job_clusters[job_cluster_key='variable_cluster'].new_cluster.custom_tags['added']: skip
job_clusters[job_cluster_key='variable_cluster'].new_cluster.custom_tags['changed']: skip
job_clusters[job_cluster_key='variable_cluster'].new_cluster.custom_tags['removed']: skip
job_clusters[job_cluster_key='variable_cluster'].new_cluster.spark_env_vars: skip
max_concurrent_runs: replace


Expand All @@ -21,7 +24,7 @@ Resource: resources.jobs.my_job
>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -15,5 +15,5 @@
@@ -30,5 +30,5 @@
jobs:
my_job:
- max_concurrent_runs: 1
Expand All @@ -34,20 +37,22 @@ Resource: resources.jobs.my_job
>>> cat [OUTPUT_DIR]/out.requests.txt
{
"save": true,
"changes_total": 2,
"add_count": 1,
"replace_count": 1,
"changes_total": 7,
"add_count": 3,
"replace_count": 3,
"remove_count": 1,
"resource_changes": [
{
"resource_type": "jobs",
"changes_count": 2,
"add_count": 1,
"replace_count": 1
"changes_count": 7,
"add_count": 3,
"replace_count": 3,
"remove_count": 1
}
],
"files_changed_count": 1,
"files_written_count": 1,
"skipped_changes_count": 1,
"skipped_changes_count": 6,
"state_serial": 1,
"state_lineage": "[UUID]",
"state_source": "local",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ trap cleanup EXIT
$CLI bundle deploy
job_id="$(read_id.py my_job)"

title "Inject a spark_conf key under a field defined as a complex variable"
title "Edit fields under complex variables"
echo
echo "spark_conf is set to a variable reference, so a remotely-added key cannot be"
echo "written into that scalar node; the change is skipped while unrelated edits still sync."
edit_resource.py jobs $job_id <<'EOF'
r["max_concurrent_runs"] = 5

for jc in r.get("job_clusters", []):
jc["new_cluster"]["spark_conf"]["spark.executor.memory"] = "4g"
cluster = r["job_clusters"][0]["new_cluster"]
cluster["spark_conf"]["spark.executor.memory"] = "4g"
cluster["init_scripts"][0]["workspace"]["destination"] = "/Workspace/updated-init.sh"

cluster = r["job_clusters"][1]["new_cluster"]
cluster["spark_env_vars"] = {"ADDED": "value"}
cluster["custom_tags"]["added"] = "new"
cluster["custom_tags"]["changed"] = "updated"
del cluster["custom_tags"]["removed"]
EOF

title "Detect and save all changes"
Expand All @@ -36,5 +41,5 @@ rm databricks.yml.backup
title "Telemetry"
echo
# The engine name is dropped because both EnvMatrix variants share this output.
# skipped_changes_count reflects the spark_conf change skipped under a variable reference.
# skipped_changes_count includes changes under both immediate and distant variable ancestors.
trace cat "$OUT_REQUESTS" | jq 'select(has("path") and .path == "/telemetry-ext") | .body.protoLogs[] | fromjson | .entry.databricks_cli_log.bundle_config_remote_sync_event | select(. != null) | del(.engine)'
Loading
Loading