Skip to content

Commit 3d39641

Browse files
ilyakuz-dbTanishqDatabricks
authored andcommitted
Restore variables in config-remote-sync (databricks#5053)
## Changes <!-- Brief summary of your changes that is easy to understand --> When config-remote-sync patches YAML files with remote changes, it now restores variable references rather than always hardcoding values. This prevents configs from losing `${var.X}` references after UI edits. Note: There is a lot of ambiguity in how to restore the variables, because it's not always clear what the user's intent is, and this is hard to describe with a simple heuristic. In this PR, we make a best-effort deterministic attempt as a first step. Supported use cases: 1. If any field that contains a variable was changed, and new values match this variable, we restore it. Safe guard 2. string template `/bundle/${bundle.target}/{var.foo}` case is also supported 3. new list item of the same type is added (job param / job task) -> if variables are used in existing items , and the field value matches the variable, we use this variable ## Why Improve the config-remote-sync experience for customers. We have received feedback that customers usually have their job parameteres defined as variables, and this PR aims to address some gaps there ## Tests <!-- How have you tested the changes? --> Added acceptance tests + tested integration in the workspace <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent e78ca42 commit 3d39641

29 files changed

Lines changed: 1153 additions & 28 deletions

File tree

acceptance/bundle/config-remote-sync/config_edits/databricks.yml.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515

1616
targets:
1717
default:
18+
mode: development
1819
resources:
1920
jobs:
2021
my_job:

acceptance/bundle/config-remote-sync/config_edits/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ Resource: resources.jobs.my_job
3535
>>> diff.py databricks.yml.backup databricks.yml
3636
--- databricks.yml.backup
3737
+++ databricks.yml
38-
@@ -24,5 +24,5 @@
38+
@@ -25,5 +25,5 @@
3939
- success@example.com
4040
on_failure:
4141
- - config-failure@example.com
4242
+ - remote-failure@example.com
4343
parameters:
4444
- name: catalog
45-
@@ -35,8 +35,6 @@
45+
@@ -36,8 +36,6 @@
4646
unit: DAYS
4747
tags:
4848
- env: config-production

acceptance/bundle/config-remote-sync/flushed_cache/databricks.yml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ resources:
1313
spark_version: $DEFAULT_SPARK_VERSION
1414
node_type_id: $NODE_TYPE_ID
1515
num_workers: 1
16+
17+
targets:
18+
default:
19+
mode: development

acceptance/bundle/config-remote-sync/formatting_preserved/databricks.yml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ resources:
3939
parameters:
4040
- {name: catalog, default: main}
4141
- {name: schema, default: dev}
42+
43+
targets:
44+
default:
45+
mode: development

acceptance/bundle/config-remote-sync/formatting_preserved/output.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ Resource: resources.jobs.my_job
4242
+ Main processing task that runs the notebook.
4343
notebook_task:
4444
notebook_path: /Users/{{workspace_user_name}}/notebook
45-
@@ -40,2 +39,3 @@
45+
@@ -40,4 +39,5 @@
4646
- {name: catalog, default: main}
4747
- {name: schema, default: dev}
4848
+ timeout_seconds: 3600
4949

50+
targets:
51+
5052
>>> [CLI] bundle destroy --auto-approve
5153
The following resources will be deleted:
5254
delete resources.jobs.my_job

acceptance/bundle/config-remote-sync/job_multiple_tasks/databricks.yml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ resources:
7676
spark_version: $DEFAULT_SPARK_VERSION
7777
node_type_id: $NODE_TYPE_ID
7878
num_workers: 1
79+
80+
targets:
81+
default:
82+
mode: development

acceptance/bundle/config-remote-sync/job_multiple_tasks/output.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Resource: resources.jobs.rename_task_job
125125
+ - task_key: b_task_renamed
126126
notebook_task:
127127
notebook_path: /Users/{{workspace_user_name}}/c_task
128-
@@ -79,7 +79,14 @@
128+
@@ -79,9 +79,16 @@
129129
- task_key: a_task
130130
notebook_task:
131131
- notebook_path: /Users/{{workspace_user_name}}/a_task
@@ -142,6 +142,8 @@ Resource: resources.jobs.rename_task_job
142142
+ notebook_path: ./synced_notebook.py
143143
+ task_key: synced_task
144144

145+
targets:
146+
145147
>>> [CLI] bundle destroy --auto-approve
146148
The following resources will be deleted:
147149
delete resources.jobs.my_job

acceptance/bundle/config-remote-sync/job_pipeline_task/databricks.yml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ resources:
1717
pipeline_task:
1818
pipeline_id: ${resources.pipelines.my_pipeline.id}
1919
full_refresh: false
20+
21+
targets:
22+
default:
23+
mode: development

acceptance/bundle/config-remote-sync/job_pipeline_task/output.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Updating deployment state...
44
Deployment complete!
55

66
=== Modify pipeline_task full_refresh to True
7-
=== Modify pipeline development to True
7+
=== Modify pipeline continuous to True
88
=== Detect and save changes
99
Detected changes in 2 resource(s):
1010

1111
Resource: resources.jobs.my_job
1212
tasks[task_key='run_pipeline'].pipeline_task.full_refresh: replace
1313

1414
Resource: resources.pipelines.my_pipeline
15-
development: replace
15+
continuous: add
1616

1717

1818

@@ -21,19 +21,20 @@ Resource: resources.pipelines.my_pipeline
2121
>>> diff.py databricks.yml.backup databricks.yml
2222
--- databricks.yml.backup
2323
+++ databricks.yml
24-
@@ -6,5 +6,5 @@
25-
my_pipeline:
26-
name: test-pipeline-[UNIQUE_NAME]
27-
- development: false
28-
+ development: true
29-
libraries:
30-
- notebook:
31-
@@ -17,3 +17,3 @@
24+
@@ -11,4 +11,5 @@
25+
path: /Users/{{workspace_user_name}}/notebook
26+
27+
+ continuous: true
28+
jobs:
29+
my_job:
30+
@@ -17,5 +18,5 @@
3231
pipeline_task:
3332
pipeline_id: ${resources.pipelines.my_pipeline.id}
3433
- full_refresh: false
3534
+ full_refresh: true
3635

36+
targets:
37+
3738
>>> [CLI] bundle destroy --auto-approve
3839
The following resources will be deleted:
3940
delete resources.jobs.my_job

acceptance/bundle/config-remote-sync/job_pipeline_task/script

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ edit_resource.py jobs $job_id <<EOF
1717
r["tasks"][0]["pipeline_task"]["full_refresh"] = True
1818
EOF
1919

20-
title "Modify pipeline development to True"
20+
title "Modify pipeline continuous to True"
21+
# Dev mode auto-sets pipelines.development=true, so flipping it would be a
22+
# no-op. Use continuous instead — it's not affected by dev mode and exercises
23+
# the same Replace path.
2124
edit_resource.py pipelines $pipeline_id <<EOF
22-
r["development"] = True
25+
r["continuous"] = True
2326
EOF
2427

2528

0 commit comments

Comments
 (0)