From 46723eb595d0a3b99de406d54f889a84f509469e Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Fri, 6 Jun 2025 17:51:09 +0200 Subject: [PATCH 01/14] translate dashboards paths before their serialized contents are read --- .../databricks.yml.tmpl | 17 +++++++ .../simple_outside_bundle_root/output.txt | 29 ++++++++++++ .../simple_outside_bundle_root/script | 19 ++++++++ .../simple_outside_bundle_root/test.toml | 44 +++++++++++++++++++ .../dashboard/simple_syncroot/output.txt | 20 +++++++-- .../dashboard/simple_syncroot/test.toml | 1 - bundle/config/mutator/translate_paths.go | 25 +++++++++-- bundle/phases/initialize.go | 3 ++ 8 files changed, 150 insertions(+), 8 deletions(-) create mode 100644 acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl create mode 100644 acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt create mode 100644 acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script create mode 100644 acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl new file mode 100644 index 0000000000..403f932eda --- /dev/null +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl @@ -0,0 +1,17 @@ +bundle: + name: deploy-dashboard-outside-bundle-root-$UNIQUE_NAME + +sync: + paths: + - .. + include: + - .. + +resources: + dashboards: + dashboard1: + display_name: $DASHBOARD_DISPLAY_NAME + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID + embed_credentials: true + file_path: ../sample-dashboard.lvdash.json + parent_path: /Users/$CURRENT_USER_NAME diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt new file mode 100644 index 0000000000..abf65dc864 --- /dev/null +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt @@ -0,0 +1,29 @@ + +>>> cp [TESTROOT]/bundle/deploy/dashboard/simple_outside_bundle_root/../simple/sample-dashboard.lvdash.json ../. + +>>> ls .. +001 +sample-dashboard.lvdash.json + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-outside-bundle-root-[UNIQUE_NAME]/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +>>> [CLI] lakeview get [DASHBOARD_ID] +{ + "lifecycle_state": "ACTIVE", + "parent_path": "/Users/[USERNAME]", + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" +} + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete dashboard dashboard1 + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-outside-bundle-root-[UNIQUE_NAME]/default + +Deleting files... +Destroy complete! diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script new file mode 100644 index 0000000000..bec261a97d --- /dev/null +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script @@ -0,0 +1,19 @@ +DASHBOARD_DISPLAY_NAME="test bundle-deploy-dashboard $(uuid)" +if [ -z "$CLOUD_ENV" ]; then + DASHBOARD_DISPLAY_NAME="test bundle/deploy/ 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally + export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234" +fi +trace cp $TESTDIR/../simple/sample-dashboard.lvdash.json ../. +trace ls .. + +export DASHBOARD_DISPLAY_NAME +envsubst < databricks.yml.tmpl > databricks.yml + +cleanup() { + trace $CLI bundle destroy --auto-approve +} +trap cleanup EXIT + +trace $CLI bundle deploy +DASHBOARD_ID=$($CLI bundle summary --output json | jq -r '.resources.dashboards.dashboard1.id') +trace $CLI lakeview get $DASHBOARD_ID | jq '{lifecycle_state, parent_path, path, serialized_dashboard}' diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml new file mode 100644 index 0000000000..406b398663 --- /dev/null +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -0,0 +1,44 @@ +Local = true +Cloud = true +RequiresWarehouse = true + +Ignore = [ + "databricks.yml", + "sample-dashboard.lvdash.json", +] + +[[Repls]] +Old = "[0-9a-f]{32}" +New = "[DASHBOARD_ID]" + +[[Repls]] +# Windows: +Old = 'The system cannot find the file specified.' +New = 'no such file or directory' + +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef" +} +''' + +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published" + +[[Server]] +Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef", + "display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903", + "lifecycle_state": "ACTIVE", + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json", + "parent_path": "/Users/tester@databricks.com", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" +} +''' + +[[Server]] +Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt index cd0f46dc7a..e9ff6d057b 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt @@ -1,9 +1,23 @@ >>> [CLI] bundle deploy -Error: failed to read serialized dashboard from file_path sample-dashboard.lvdash.json: open sample-dashboard.lvdash.json: no such file or directory +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-test-[UNIQUE_NAME]/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! +>>> [CLI] lakeview get [DASHBOARD_ID] +{ + "lifecycle_state": "ACTIVE", + "parent_path": "/Users/[USERNAME]", + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" +} >>> [CLI] bundle destroy --auto-approve -Error: failed to read serialized dashboard from file_path sample-dashboard.lvdash.json: open sample-dashboard.lvdash.json: no such file or directory +The following resources will be deleted: + delete dashboard dashboard1 -Exit code: 1 +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-test-[UNIQUE_NAME]/default + +Deleting files... +Destroy complete! diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml index 329f76ca71..406b398663 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml @@ -1,4 +1,3 @@ -Badness = "Cannot read dashboard, expecting deployment to succeed" Local = true Cloud = true RequiresWarehouse = true diff --git a/bundle/config/mutator/translate_paths.go b/bundle/config/mutator/translate_paths.go index ad707636df..1625719c1a 100644 --- a/bundle/config/mutator/translate_paths.go +++ b/bundle/config/mutator/translate_paths.go @@ -47,13 +47,22 @@ func (err ErrIsNotNotebook) Error() string { return fmt.Sprintf("file at %s is not a notebook", err.path) } -type translatePaths struct{} +type translatePaths struct { + dashboardsOnly bool +} // TranslatePaths converts paths to local notebook files into paths in the workspace file system. func TranslatePaths() bundle.Mutator { return &translatePaths{} } +// TranslatePathsDashboards converts paths to local dashboard files into paths in the workspace file system. +func TranslatePathsDashboards() bundle.Mutator { + return &translatePaths{ + dashboardsOnly: true, + } +} + func (m *translatePaths) Name() string { return "TranslatePaths" } @@ -297,13 +306,21 @@ func (m *translatePaths) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn err := b.Config.Mutate(func(v dyn.Value) (dyn.Value, error) { var err error - for _, fn := range []func(context.Context, dyn.Value) (dyn.Value, error){ + + translations := []func(context.Context, dyn.Value) (dyn.Value, error){ t.applyJobTranslations, t.applyPipelineTranslations, t.applyArtifactTranslations, - t.applyDashboardTranslations, t.applyAppsTranslations, - } { + } + + if m.dashboardsOnly { + translations = []func(context.Context, dyn.Value) (dyn.Value, error){ + t.applyDashboardTranslations, + } + } + + for _, fn := range translations { v, err = fn(ctx, v) if err != nil { return dyn.InvalidValue, err diff --git a/bundle/phases/initialize.go b/bundle/phases/initialize.go index c3d3d27656..e37725a6d4 100644 --- a/bundle/phases/initialize.go +++ b/bundle/phases/initialize.go @@ -127,6 +127,9 @@ func Initialize(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { // Configure use of WSFS for reads if the CLI is running on Databricks. mutator.ConfigureWSFS(), + // Translate dashboards paths before ProcessStaticResources because the latter is reading from these paths + mutator.TranslatePathsDashboards(), + // Static resources (e.g. YAML) are already loaded, we initialize and normalize them before Python resourcemutator.ProcessStaticResources(), From 88026400963a4703d206b91ae043d4246aab5f3b Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Tue, 10 Jun 2025 13:53:57 +0200 Subject: [PATCH 02/14] update the output of bundle/debug acceptance test --- acceptance/bundle/debug/out.stderr.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/acceptance/bundle/debug/out.stderr.txt b/acceptance/bundle/debug/out.stderr.txt index ea082fac30..9aba8a6e96 100644 --- a/acceptance/bundle/debug/out.stderr.txt +++ b/acceptance/bundle/debug/out.stderr.txt @@ -41,6 +41,7 @@ 10:07:59 Debug: Apply pid=12345 mutator=validate:volume-path 10:07:59 Debug: Apply pid=12345 mutator=ApplyTargetMode 10:07:59 Debug: Apply pid=12345 mutator=ConfigureWSFS +10:07:59 Debug: Apply pid=12345 mutator=TranslatePaths 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=ResolveVariableReferences(resources) 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=NormalizePaths From e30ebe9c42f26d84d136db49585ddf3342ee6c8f Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:14:18 +0200 Subject: [PATCH 03/14] add a replacement for windows file path in test.toml --- .../deploy/dashboard/simple_outside_bundle_root/test.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml index 406b398663..f7e9e41042 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -11,6 +11,10 @@ Ignore = [ Old = "[0-9a-f]{32}" New = "[DASHBOARD_ID]" +[[Repls]] +Old = '\\' +New = '/' + [[Repls]] # Windows: Old = 'The system cannot find the file specified.' From d974ee8b6fca284a1ca67e10586043d92da38457 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:33:39 +0200 Subject: [PATCH 04/14] remove tracing cp and ls commands (so they do not produce output) --- .../deploy/dashboard/simple_outside_bundle_root/output.txt | 6 ------ .../deploy/dashboard/simple_outside_bundle_root/script | 3 +-- .../deploy/dashboard/simple_outside_bundle_root/test.toml | 4 ---- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt index abf65dc864..df710ff2e3 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt @@ -1,10 +1,4 @@ ->>> cp [TESTROOT]/bundle/deploy/dashboard/simple_outside_bundle_root/../simple/sample-dashboard.lvdash.json ../. - ->>> ls .. -001 -sample-dashboard.lvdash.json - >>> [CLI] bundle deploy Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-outside-bundle-root-[UNIQUE_NAME]/default/files... Deploying resources... diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script index bec261a97d..873d374fbb 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/script @@ -3,8 +3,7 @@ if [ -z "$CLOUD_ENV" ]; then DASHBOARD_DISPLAY_NAME="test bundle/deploy/ 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234" fi -trace cp $TESTDIR/../simple/sample-dashboard.lvdash.json ../. -trace ls .. +cp $TESTDIR/../simple/sample-dashboard.lvdash.json ../. export DASHBOARD_DISPLAY_NAME envsubst < databricks.yml.tmpl > databricks.yml diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml index f7e9e41042..406b398663 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -11,10 +11,6 @@ Ignore = [ Old = "[0-9a-f]{32}" New = "[DASHBOARD_ID]" -[[Repls]] -Old = '\\' -New = '/' - [[Repls]] # Windows: Old = 'The system cannot find the file specified.' From ae34c2a747c65ed22534f768d6dd74d8b8b247a8 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:18:19 +0200 Subject: [PATCH 05/14] add NEXT_CHANGELOG.md --- NEXT_CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 3ea6a080c5..728fff9bd5 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -1,6 +1,6 @@ # NEXT CHANGELOG -## Release v0.256.0 +## Release v0.255.0 ### Notable Changes @@ -9,5 +9,6 @@ ### CLI ### Bundles +* Fix reading dashboard contents when the sync root is different than the bundle root ([#3006](https://github.com/databricks/cli/pull/3006)) ### API Changes From 34999b3ed18cccfe3a8351c302384024a12b3c92 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 10:22:31 +0200 Subject: [PATCH 06/14] remove server mocks from acceptance tests --- .../simple_outside_bundle_root/output.txt | 8 +++---- .../simple_outside_bundle_root/test.toml | 24 ------------------- .../dashboard/simple_syncroot/output.txt | 8 +++---- .../dashboard/simple_syncroot/test.toml | 24 ------------------- 4 files changed, 8 insertions(+), 56 deletions(-) diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt index df710ff2e3..30529dd138 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt @@ -5,12 +5,12 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> [CLI] lakeview get [DASHBOARD_ID] +>>> [CLI] lakeview get [UUID] { - "lifecycle_state": "ACTIVE", + "lifecycle_state": null, "parent_path": "/Users/[USERNAME]", - "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" + "path": null, + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\"}]}\n" } >>> [CLI] bundle destroy --auto-approve diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml index 406b398663..03d7bf80b8 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -16,29 +16,5 @@ New = "[DASHBOARD_ID]" Old = 'The system cannot find the file specified.' New = 'no such file or directory' -[[Server]] -Pattern = "POST /api/2.0/lakeview/dashboards" -Response.Body = ''' -{ - "dashboard_id":"1234567890abcdef1234567890abcdef" -} -''' - -[[Server]] -Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published" - -[[Server]] -Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}" -Response.Body = ''' -{ - "dashboard_id":"1234567890abcdef1234567890abcdef", - "display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903", - "lifecycle_state": "ACTIVE", - "path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json", - "parent_path": "/Users/tester@databricks.com", - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" -} -''' - [[Server]] Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt index e9ff6d057b..c21719c0f4 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt @@ -5,12 +5,12 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> [CLI] lakeview get [DASHBOARD_ID] +>>> [CLI] lakeview get [UUID] { - "lifecycle_state": "ACTIVE", + "lifecycle_state": null, "parent_path": "/Users/[USERNAME]", - "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" + "path": null, + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\"}]}\n" } >>> [CLI] bundle destroy --auto-approve diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml index 406b398663..03d7bf80b8 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml @@ -16,29 +16,5 @@ New = "[DASHBOARD_ID]" Old = 'The system cannot find the file specified.' New = 'no such file or directory' -[[Server]] -Pattern = "POST /api/2.0/lakeview/dashboards" -Response.Body = ''' -{ - "dashboard_id":"1234567890abcdef1234567890abcdef" -} -''' - -[[Server]] -Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published" - -[[Server]] -Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}" -Response.Body = ''' -{ - "dashboard_id":"1234567890abcdef1234567890abcdef", - "display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903", - "lifecycle_state": "ACTIVE", - "path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json", - "parent_path": "/Users/tester@databricks.com", - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" -} -''' - [[Server]] Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" From 51497acf87b155a0e54fcd22f09b15f7d52f5442 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:58:01 +0200 Subject: [PATCH 07/14] move TranslatePathsDashboards call to happen after NormalizePaths --- .../config/mutator/resourcemutator/process_static_resources.go | 3 +++ bundle/phases/initialize.go | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundle/config/mutator/resourcemutator/process_static_resources.go b/bundle/config/mutator/resourcemutator/process_static_resources.go index cef71c62b3..6e365a0340 100644 --- a/bundle/config/mutator/resourcemutator/process_static_resources.go +++ b/bundle/config/mutator/resourcemutator/process_static_resources.go @@ -49,6 +49,9 @@ func (p processStaticResources) Apply(ctx context.Context, b *bundle.Bundle) dia "variables", ), mutator.NormalizePaths(), + + // Translate dashboards paths before NormalizeAndInitializeResources and after NormalizePaths + mutator.TranslatePathsDashboards(), ) if diags.HasError() { return diags diff --git a/bundle/phases/initialize.go b/bundle/phases/initialize.go index e37725a6d4..c3d3d27656 100644 --- a/bundle/phases/initialize.go +++ b/bundle/phases/initialize.go @@ -127,9 +127,6 @@ func Initialize(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { // Configure use of WSFS for reads if the CLI is running on Databricks. mutator.ConfigureWSFS(), - // Translate dashboards paths before ProcessStaticResources because the latter is reading from these paths - mutator.TranslatePathsDashboards(), - // Static resources (e.g. YAML) are already loaded, we initialize and normalize them before Python resourcemutator.ProcessStaticResources(), From 56a4bd4dbd1d72684fd2b2553d56a13090759119 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:39:30 +0200 Subject: [PATCH 08/14] update bundle/debug test --- acceptance/bundle/debug/out.stderr.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/bundle/debug/out.stderr.txt b/acceptance/bundle/debug/out.stderr.txt index 9aba8a6e96..60de4430e0 100644 --- a/acceptance/bundle/debug/out.stderr.txt +++ b/acceptance/bundle/debug/out.stderr.txt @@ -41,10 +41,10 @@ 10:07:59 Debug: Apply pid=12345 mutator=validate:volume-path 10:07:59 Debug: Apply pid=12345 mutator=ApplyTargetMode 10:07:59 Debug: Apply pid=12345 mutator=ConfigureWSFS -10:07:59 Debug: Apply pid=12345 mutator=TranslatePaths 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=ResolveVariableReferences(resources) 10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=NormalizePaths +10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=TranslatePaths 10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load) 10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(init) 10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load_resources) From df2454a01a8477ecd4682d10be06bc2b1aa4c9b0 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:23:29 +0200 Subject: [PATCH 09/14] treat new lines in json files in windows as \n --- acceptance/bundle/deploy/dashboard/.gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 acceptance/bundle/deploy/dashboard/.gitattributes diff --git a/acceptance/bundle/deploy/dashboard/.gitattributes b/acceptance/bundle/deploy/dashboard/.gitattributes new file mode 100644 index 0000000000..19ff4247cd --- /dev/null +++ b/acceptance/bundle/deploy/dashboard/.gitattributes @@ -0,0 +1,2 @@ +# treat new lines in json files in windows as \n +*.json text eol=lf From ed87b1b6109fe04249e68f996038e427c84753f4 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:54:07 +0200 Subject: [PATCH 10/14] Revert "remove server mocks from acceptance tests" This reverts commit af83a40577ac0cb5a5ac2ff6c4f5de783909a44c. --- .../simple_outside_bundle_root/output.txt | 8 +++---- .../simple_outside_bundle_root/test.toml | 24 +++++++++++++++++++ .../dashboard/simple_syncroot/output.txt | 8 +++---- .../dashboard/simple_syncroot/test.toml | 24 +++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt index 30529dd138..df710ff2e3 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/output.txt @@ -5,12 +5,12 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> [CLI] lakeview get [UUID] +>>> [CLI] lakeview get [DASHBOARD_ID] { - "lifecycle_state": null, + "lifecycle_state": "ACTIVE", "parent_path": "/Users/[USERNAME]", - "path": null, - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\"}]}\n" + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } >>> [CLI] bundle destroy --auto-approve diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml index 03d7bf80b8..406b398663 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/test.toml @@ -16,5 +16,29 @@ New = "[DASHBOARD_ID]" Old = 'The system cannot find the file specified.' New = 'no such file or directory' +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef" +} +''' + +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published" + +[[Server]] +Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef", + "display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903", + "lifecycle_state": "ACTIVE", + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json", + "parent_path": "/Users/tester@databricks.com", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" +} +''' + [[Server]] Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt index c21719c0f4..e9ff6d057b 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/output.txt @@ -5,12 +5,12 @@ Deploying resources... Updating deployment state... Deployment complete! ->>> [CLI] lakeview get [UUID] +>>> [CLI] lakeview get [DASHBOARD_ID] { - "lifecycle_state": null, + "lifecycle_state": "ACTIVE", "parent_path": "/Users/[USERNAME]", - "path": null, - "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\"}]}\n" + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" } >>> [CLI] bundle destroy --auto-approve diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml index 03d7bf80b8..406b398663 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/test.toml @@ -16,5 +16,29 @@ New = "[DASHBOARD_ID]" Old = 'The system cannot find the file specified.' New = 'no such file or directory' +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef" +} +''' + +[[Server]] +Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published" + +[[Server]] +Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}" +Response.Body = ''' +{ + "dashboard_id":"1234567890abcdef1234567890abcdef", + "display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903", + "lifecycle_state": "ACTIVE", + "path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json", + "parent_path": "/Users/tester@databricks.com", + "serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}" +} +''' + [[Server]] Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}" From 125a785adc1ce64c799da4707be13862cdea756a Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:52:58 +0200 Subject: [PATCH 11/14] improve line comment --- .../mutator/resourcemutator/process_static_resources.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundle/config/mutator/resourcemutator/process_static_resources.go b/bundle/config/mutator/resourcemutator/process_static_resources.go index 6e365a0340..f227bcfdf4 100644 --- a/bundle/config/mutator/resourcemutator/process_static_resources.go +++ b/bundle/config/mutator/resourcemutator/process_static_resources.go @@ -50,7 +50,9 @@ func (p processStaticResources) Apply(ctx context.Context, b *bundle.Bundle) dia ), mutator.NormalizePaths(), - // Translate dashboards paths before NormalizeAndInitializeResources and after NormalizePaths + // Translate dashboard paths into paths in the workspace file system + // This must occur after NormalizePaths but before NormalizeAndInitializeResources, + // since the latter reads dashboard files and requires fully resolved paths. mutator.TranslatePathsDashboards(), ) if diags.HasError() { From 0947f1608b82fee17609b1b21e685ddd2d39a700 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:39:43 +0200 Subject: [PATCH 12/14] remove .gitattributes --- acceptance/bundle/deploy/dashboard/.gitattributes | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 acceptance/bundle/deploy/dashboard/.gitattributes diff --git a/acceptance/bundle/deploy/dashboard/.gitattributes b/acceptance/bundle/deploy/dashboard/.gitattributes deleted file mode 100644 index 19ff4247cd..0000000000 --- a/acceptance/bundle/deploy/dashboard/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# treat new lines in json files in windows as \n -*.json text eol=lf From 81972c4679b6d496ac81915b0b8f838e119e08c8 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:43:49 +0200 Subject: [PATCH 13/14] add comments to bundle setups for dashboards tests --- .../deploy/dashboard/nested-folders/databricks.yml.tmpl | 5 +++++ .../bundle/deploy/dashboard/simple/databricks.yml.tmpl | 5 +++++ .../dashboard/simple_outside_bundle_root/databricks.yml.tmpl | 5 +++++ .../deploy/dashboard/simple_syncroot/databricks.yml.tmpl | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/acceptance/bundle/deploy/dashboard/nested-folders/databricks.yml.tmpl b/acceptance/bundle/deploy/dashboard/nested-folders/databricks.yml.tmpl index f257a2f8df..87620709a3 100644 --- a/acceptance/bundle/deploy/dashboard/nested-folders/databricks.yml.tmpl +++ b/acceptance/bundle/deploy/dashboard/nested-folders/databricks.yml.tmpl @@ -1,3 +1,8 @@ +# +# Acceptance test for deploying dashboards with the following setup: +# 1. dashboard file is inside the bundle root, but in a separate file from the .yml file +# 2. sync root is the same as the bundle root +# bundle: name: deploy-dashboard-nested-folders-$UNIQUE_NAME diff --git a/acceptance/bundle/deploy/dashboard/simple/databricks.yml.tmpl b/acceptance/bundle/deploy/dashboard/simple/databricks.yml.tmpl index 27b425c98a..682da0320b 100644 --- a/acceptance/bundle/deploy/dashboard/simple/databricks.yml.tmpl +++ b/acceptance/bundle/deploy/dashboard/simple/databricks.yml.tmpl @@ -1,3 +1,8 @@ +# +# Acceptance test for deploying dashboards with the following setup: +# 1. dashboard file is inside the bundle root +# 2. sync root is the same as the bundle root +# bundle: name: deploy-dashboard-test-$UNIQUE_NAME diff --git a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl index 403f932eda..6b3de54b08 100644 --- a/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl +++ b/acceptance/bundle/deploy/dashboard/simple_outside_bundle_root/databricks.yml.tmpl @@ -1,3 +1,8 @@ +# +# Acceptance test for deploying dashboards with the following setup: +# 1. dashboard file is outside the bundle root +# 2. sync root is one level above bundle root +# bundle: name: deploy-dashboard-outside-bundle-root-$UNIQUE_NAME diff --git a/acceptance/bundle/deploy/dashboard/simple_syncroot/databricks.yml.tmpl b/acceptance/bundle/deploy/dashboard/simple_syncroot/databricks.yml.tmpl index 833da56a6b..de130f6672 100644 --- a/acceptance/bundle/deploy/dashboard/simple_syncroot/databricks.yml.tmpl +++ b/acceptance/bundle/deploy/dashboard/simple_syncroot/databricks.yml.tmpl @@ -1,3 +1,8 @@ +# +# Acceptance test for deploying dashboards with the following setup: +# 1. dashboard file is within the bundle root +# 2. sync root is one level above bundle root +# bundle: name: deploy-dashboard-test-$UNIQUE_NAME From aaaa492e9b978e77254956f70db52b4885dcbe52 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:09:34 +0200 Subject: [PATCH 14/14] set NEXT_CHANGELOG.md to version v0.256.0 --- NEXT_CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 728fff9bd5..49340c6c82 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -1,6 +1,6 @@ # NEXT CHANGELOG -## Release v0.255.0 +## Release v0.256.0 ### Notable Changes