diff --git a/acceptance/cmd/workspace/export-dir-dashboard/dashboard.lvdash.json b/acceptance/cmd/workspace/export-dir-dashboard/dashboard.lvdash.json new file mode 100644 index 00000000000..0a39c4a05c7 --- /dev/null +++ b/acceptance/cmd/workspace/export-dir-dashboard/dashboard.lvdash.json @@ -0,0 +1,11 @@ +{ + "pages": [ + { + "name": "main", + "displayName": "Main", + "pageType": "PAGE_TYPE_CANVAS", + "layoutVersion": "GRID_V1", + "layout": [] + } + ] +} diff --git a/acceptance/cmd/workspace/export-dir-dashboard/out.test.toml b/acceptance/cmd/workspace/export-dir-dashboard/out.test.toml new file mode 100644 index 00000000000..bc1000590f3 --- /dev/null +++ b/acceptance/cmd/workspace/export-dir-dashboard/out.test.toml @@ -0,0 +1,4 @@ +Cloud = true +RequiresWarehouse = true +GOOS.windows = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] diff --git a/acceptance/cmd/workspace/export-dir-dashboard/output.txt b/acceptance/cmd/workspace/export-dir-dashboard/output.txt new file mode 100644 index 00000000000..21c8b788853 --- /dev/null +++ b/acceptance/cmd/workspace/export-dir-dashboard/output.txt @@ -0,0 +1,9 @@ + +>>> [CLI] workspace mkdirs /Workspace/Users/[USERNAME]/export-dir-dashboard-[UNIQUE_NAME] + +>>> [CLI] workspace export-dir /Workspace/Users/[USERNAME]/export-dir-dashboard-[UNIQUE_NAME] [TEST_TMP_DIR]/export +Exporting files from /Workspace/Users/[USERNAME]/export-dir-dashboard-[UNIQUE_NAME] +/Workspace/Users/[USERNAME]/export-dir-dashboard-[UNIQUE_NAME]/export-dir-dashboard-[UNIQUE_NAME].lvdash.json -> [TEST_TMP_DIR]/export/export-dir-dashboard-[UNIQUE_NAME].lvdash.json +Export complete + +>>> assert_exists.py [TEST_TMP_DIR]/export/export-dir-dashboard-[UNIQUE_NAME].lvdash.json diff --git a/acceptance/cmd/workspace/export-dir-dashboard/script b/acceptance/cmd/workspace/export-dir-dashboard/script new file mode 100644 index 00000000000..febb56173c4 --- /dev/null +++ b/acceptance/cmd/workspace/export-dir-dashboard/script @@ -0,0 +1,29 @@ +DASHBOARD_NAME="export-dir-dashboard-$UNIQUE_NAME" +DASHBOARD_DIR="/Workspace/Users/$CURRENT_USER_NAME/export-dir-dashboard-$UNIQUE_NAME" +dashboard_id="" + +cleanup() { + if [ -n "$dashboard_id" ]; then + $CLI lakeview trash "$dashboard_id" >> LOG.cleanup 2>&1 || true + fi + $CLI workspace delete "$DASHBOARD_DIR" --recursive >> LOG.cleanup 2>&1 || true +} +trap cleanup EXIT + +trace $CLI workspace mkdirs "$DASHBOARD_DIR" + +dashboard_id=$($CLI lakeview create \ + --display-name "$DASHBOARD_NAME" \ + --warehouse-id "$TEST_DEFAULT_WAREHOUSE_ID" \ + --serialized-dashboard "$(cat dashboard.lvdash.json)" \ + --json "{\"parent_path\": \"$DASHBOARD_DIR\"}" \ + -o json | jq -r '.dashboard_id') +add_repl "$dashboard_id" DASHBOARD_ID + +mkdir -p "$TEST_TMP_DIR/export" +trace $CLI workspace export-dir "$DASHBOARD_DIR" "$TEST_TMP_DIR/export" + +# The Lakeview backend normalizes the serialized dashboard on create (e.g. it +# drops an empty "layout": []), so the exported content is not byte-identical to +# the input. Assert the dashboard was exported rather than diffing the content. +trace assert_exists.py "$TEST_TMP_DIR/export/$DASHBOARD_NAME.lvdash.json" diff --git a/acceptance/cmd/workspace/export-dir-dashboard/test.toml b/acceptance/cmd/workspace/export-dir-dashboard/test.toml new file mode 100644 index 00000000000..53f632d9741 --- /dev/null +++ b/acceptance/cmd/workspace/export-dir-dashboard/test.toml @@ -0,0 +1,12 @@ +Cloud = true +RequiresWarehouse = true + +# export-dir prints the local destination with OS-native separators, so the +# output diverges on Windows. The exported-dashboard behavior is OS-independent, +# so cover it on Linux/macOS only. +GOOS.windows = false + +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] +Ignore = [ + "export", +] diff --git a/cmd/workspace/workspace/export_dir.go b/cmd/workspace/workspace/export_dir.go index 77056f4d28c..362b6e4e30b 100644 --- a/cmd/workspace/workspace/export_dir.go +++ b/cmd/workspace/workspace/export_dir.go @@ -57,7 +57,6 @@ func isFileSizeError(err error) bool { // These will be skipped with a warning during export-dir. var nonExportableTypes = []workspace.ObjectType{ workspace.ObjectTypeLibrary, - workspace.ObjectTypeDashboard, workspace.ObjectTypeRepo, // MLFLOW_EXPERIMENT is not defined as a constant in the SDK workspace.ObjectType("MLFLOW_EXPERIMENT"),