From 88d4fe5b6a7c6eb2e9036ae8f5f36a66da3ba3a2 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 11:50:49 +0200 Subject: [PATCH 1/7] Added experimental.skip_artifacts_cleanup flag --- .../artifacts/whl_no_cleanup/.gitignore | 3 +++ .../artifacts/whl_no_cleanup/databricks.yml | 15 +++++++++++ .../whl_no_cleanup/my_test_code/__init__.py | 2 ++ .../whl_no_cleanup/my_test_code/__main__.py | 16 +++++++++++ .../artifacts/whl_no_cleanup/output.txt | 27 +++++++++++++++++++ .../bundle/artifacts/whl_no_cleanup/script | 12 +++++++++ .../bundle/artifacts/whl_no_cleanup/setup.py | 15 +++++++++++ .../deploy-artifact-path-type/output.txt | 8 ++++++ .../telemetry/deploy-compute-type/output.txt | 8 ++++++ .../out.telemetry.txt | 4 +++ .../bundle/telemetry/deploy-mode/output.txt | 8 ++++++ .../deploy-name-prefix/custom/output.txt | 4 +++ .../mode-development/output.txt | 4 +++ .../deploy-no-uuid/out.telemetry.txt | 4 +++ .../telemetry/deploy-target-count/output.txt | 4 +++ .../deploy-variable-count/output.txt | 4 +++ .../deploy-whl-artifacts/databricks.yml | 4 +++ .../telemetry/deploy-whl-artifacts/output.txt | 12 +++++++-- .../bundle/telemetry/deploy/out.telemetry.txt | 4 +++ bundle/artifacts/upload.go | 7 +++++ bundle/config/experimental.go | 5 ++++ bundle/internal/schema/annotations.yml | 3 +++ bundle/schema/jsonschema.json | 3 +++ 23 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/.gitignore create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__init__.py create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__main__.py create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/output.txt create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/script create mode 100644 acceptance/bundle/artifacts/whl_no_cleanup/setup.py diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/.gitignore b/acceptance/bundle/artifacts/whl_no_cleanup/.gitignore new file mode 100644 index 0000000000..f03e23bc26 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/.gitignore @@ -0,0 +1,3 @@ +build/ +*.egg-info +.databricks diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml b/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml new file mode 100644 index 0000000000..302120b283 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml @@ -0,0 +1,15 @@ +experimental: + skip_artifacts_cleanup: true + +resources: + jobs: + test_job: + name: "[${bundle.target}] My Wheel Job" + tasks: + - task_key: TestTask + existing_cluster_id: "0717-aaaaa-bbbbbb" + python_wheel_task: + package_name: "my_test_code" + entry_point: "run" + libraries: + - whl: ./dist/*.whl diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__init__.py b/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__init__.py new file mode 100644 index 0000000000..909f1f3220 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__init__.py @@ -0,0 +1,2 @@ +__version__ = "0.0.1" +__author__ = "Databricks" diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__main__.py b/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__main__.py new file mode 100644 index 0000000000..ea918ce2d5 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/my_test_code/__main__.py @@ -0,0 +1,16 @@ +""" +The entry point of the Python Wheel +""" + +import sys + + +def main(): + # This method will print the provided arguments + print("Hello from my func") + print("Got arguments:") + print(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/output.txt b/acceptance/bundle/artifacts/whl_no_cleanup/output.txt new file mode 100644 index 0000000000..b5b5136107 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/output.txt @@ -0,0 +1,27 @@ + +>>> [CLI] bundle deploy +Building python_artifact... +Uploading dist/my_test_code-0.0.1-py3-none-any.whl... +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +>>> find.py --expect 1 whl +dist/my_test_code-0.0.1-py3-none-any.whl + +=== Expecting 1 wheels to be uploaded +>>> jq .path +"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl" +"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/dist/my_test_code-0.0.1-py3-none-any.whl" + +>>> [CLI] bundle deploy +Building python_artifact... +Uploading dist/my_test_code-0.0.1-py3-none-any.whl... +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +=== No calls to delete internal folder expected +>>> jq -s .[] | select(.path=="/api/2.0/workspace/delete") | select(.body.path | test(".*/artifacts/.internal")) out.requests.txt diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/script b/acceptance/bundle/artifacts/whl_no_cleanup/script new file mode 100644 index 0000000000..718508ce1c --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/script @@ -0,0 +1,12 @@ +trace $CLI bundle deploy + +trace find.py --expect 1 whl + +title "Expecting 1 wheels to be uploaded" +trace jq .path < out.requests.txt | grep import | grep whl | sort + +trace $CLI bundle deploy +title "No calls to delete internal folder expected" +trace jq -s '.[] | select(.path=="/api/2.0/workspace/delete") | select(.body.path | test(".*/artifacts/.internal"))' out.requests.txt + +rm out.requests.txt diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/setup.py b/acceptance/bundle/artifacts/whl_no_cleanup/setup.py new file mode 100644 index 0000000000..7a1317b2f5 --- /dev/null +++ b/acceptance/bundle/artifacts/whl_no_cleanup/setup.py @@ -0,0 +1,15 @@ +from setuptools import setup, find_packages + +import my_test_code + +setup( + name="my_test_code", + version=my_test_code.__version__, + author=my_test_code.__author__, + url="https://databricks.com", + author_email="john.doe@databricks.com", + description="my test wheel", + packages=find_packages(include=["my_test_code"]), + entry_points={"group_1": "run=my_test_code.__main__:main"}, + install_requires=["setuptools"], +) diff --git a/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt b/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt index 7789a2513a..47c522c6c3 100644 --- a/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt +++ b/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt @@ -33,6 +33,10 @@ Deployment complete! "lookup_variable_count": 0, "target_count": 2, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false @@ -77,6 +81,10 @@ Deployment complete! "lookup_variable_count": 0, "target_count": 2, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-compute-type/output.txt b/acceptance/bundle/telemetry/deploy-compute-type/output.txt index 3dbaaa0af6..9f480b50e1 100644 --- a/acceptance/bundle/telemetry/deploy-compute-type/output.txt +++ b/acceptance/bundle/telemetry/deploy-compute-type/output.txt @@ -17,6 +17,10 @@ Deployment complete! "key": "presets_name_prefix_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false @@ -39,6 +43,10 @@ Deployment complete! "key": "presets_name_prefix_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt b/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt index 640249652b..7c0542d10b 100644 --- a/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt @@ -33,6 +33,10 @@ "lookup_variable_count": 0, "target_count": 1, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-mode/output.txt b/acceptance/bundle/telemetry/deploy-mode/output.txt index be91dc2cf4..dbdacc5d7a 100644 --- a/acceptance/bundle/telemetry/deploy-mode/output.txt +++ b/acceptance/bundle/telemetry/deploy-mode/output.txt @@ -39,6 +39,10 @@ A common practice is to use a username or principal name in this path, i.e. use "lookup_variable_count": 0, "target_count": 2, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false @@ -83,6 +87,10 @@ A common practice is to use a username or principal name in this path, i.e. use "lookup_variable_count": 0, "target_count": 2, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt b/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt index 453a29af3c..f689c2f32f 100644 --- a/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt +++ b/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt @@ -33,6 +33,10 @@ Deployment complete! "key": "presets_name_prefix_is_set", "value": true }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt b/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt index 872d0a4255..dd514ec03d 100644 --- a/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt +++ b/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt @@ -33,6 +33,10 @@ Deployment complete! "key": "presets_name_prefix_is_set", "value": true }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt b/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt index 20b2d9eabd..b678795f1b 100644 --- a/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt @@ -40,6 +40,10 @@ "key": "presets_name_prefix_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-target-count/output.txt b/acceptance/bundle/telemetry/deploy-target-count/output.txt index 3143977774..dd6a69ad0f 100644 --- a/acceptance/bundle/telemetry/deploy-target-count/output.txt +++ b/acceptance/bundle/telemetry/deploy-target-count/output.txt @@ -28,6 +28,10 @@ Deployment complete! "lookup_variable_count": 0, "target_count": 3, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-variable-count/output.txt b/acceptance/bundle/telemetry/deploy-variable-count/output.txt index 044a6d83cd..fcd18efa37 100644 --- a/acceptance/bundle/telemetry/deploy-variable-count/output.txt +++ b/acceptance/bundle/telemetry/deploy-variable-count/output.txt @@ -28,6 +28,10 @@ Deployment complete! "lookup_variable_count": 2, "target_count": 1, "bool_values": [ + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml b/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml index 556ec0568e..d60df6a930 100644 --- a/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml +++ b/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml @@ -1,9 +1,12 @@ variables: wrapper: default: false + skip_artifacts_cleanup: + default: false experimental: python_wheel_wrapper: ${var.wrapper} + skip_artifacts_cleanup: ${var.skip_artifacts_cleanup} targets: one: @@ -15,6 +18,7 @@ targets: two: variables: wrapper: true + skip_artifacts_cleanup: true artifacts: test: type: whl diff --git a/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt b/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt index 60a8d90849..2d43b17f7b 100644 --- a/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt +++ b/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt @@ -32,7 +32,7 @@ Deployment complete! "resource_app_count": 0, "experimental": { "configuration_file_count": 1, - "variable_count": 1, + "variable_count": 2, "complex_variable_count": 0, "lookup_variable_count": 0, "target_count": 2, @@ -45,6 +45,10 @@ Deployment complete! "key": "artifact_files_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false @@ -84,7 +88,7 @@ Deployment complete! "resource_app_count": 0, "experimental": { "configuration_file_count": 1, - "variable_count": 1, + "variable_count": 2, "complex_variable_count": 0, "lookup_variable_count": 0, "target_count": 2, @@ -101,6 +105,10 @@ Deployment complete! "key": "artifact_dynamic_version_is_set", "value": true }, + { + "key": "skip_artifacts_cleanup", + "value": true + }, { "key": "python_wheel_wrapper_is_set", "value": true diff --git a/acceptance/bundle/telemetry/deploy/out.telemetry.txt b/acceptance/bundle/telemetry/deploy/out.telemetry.txt index ad614821d8..9e38b05e62 100644 --- a/acceptance/bundle/telemetry/deploy/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy/out.telemetry.txt @@ -46,6 +46,10 @@ "key": "presets_name_prefix_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false diff --git a/bundle/artifacts/upload.go b/bundle/artifacts/upload.go index 20e2b57031..30a779aa39 100644 --- a/bundle/artifacts/upload.go +++ b/bundle/artifacts/upload.go @@ -21,6 +21,13 @@ func (m *cleanUp) Name() string { } func (m *cleanUp) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { + skipArtifactsCleanup := b.Config.Experimental != nil && b.Config.Experimental.SkipArtifactsCleanup + b.Metrics.AddBoolValue("skip_artifacts_cleanup", skipArtifactsCleanup) + if skipArtifactsCleanup { + log.Info(ctx, "Skip cleaning up artifacts folder") + return nil + } + client, uploadPath, diags := libraries.GetFilerForLibrariesCleanup(ctx, b) if diags.HasError() { return diags diff --git a/bundle/config/experimental.go b/bundle/config/experimental.go index 7fec87ed64..181d52ac06 100644 --- a/bundle/config/experimental.go +++ b/bundle/config/experimental.go @@ -32,6 +32,11 @@ type Experimental struct { // Python configures loading of Python code defined with 'databricks-bundles' package. Python Python `json:"python,omitempty"` + + // SkipArtifactsCleanup determines whether to skip cleaning up the .internal folder + // containing build artifacts such as wheels. When set to true, the .internal folder + // and its contents will be preserved after bundle operations complete. + SkipArtifactsCleanup bool `json:"skip_artifacts_cleanup,omitempty"` } type Python struct { diff --git a/bundle/internal/schema/annotations.yml b/bundle/internal/schema/annotations.yml index b9955647a9..2906f15566 100644 --- a/bundle/internal/schema/annotations.yml +++ b/bundle/internal/schema/annotations.yml @@ -75,6 +75,9 @@ github.com/databricks/cli/bundle/config.Experimental: "scripts": "description": |- The commands to run. + "skip_artifacts_cleanup": + "description": |- + Determines whether to skip cleaning up the .internal folder "use_legacy_run_as": "description": |- Whether to use the legacy run_as behavior. diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index b75dd2c853..01b1144609 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -1716,6 +1716,9 @@ "description": "The commands to run.", "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.Command" }, + "skip_artifacts_cleanup": { + "$ref": "#/$defs/bool" + }, "use_legacy_run_as": { "description": "Whether to use the legacy run_as behavior.", "$ref": "#/$defs/bool" From cdb651cd51a27ccfc87b0cbc165dcff007a47401 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 11:54:46 +0200 Subject: [PATCH 2/7] added changelog --- NEXT_CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 655f3c11dc..d8a95e94ea 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -9,5 +9,6 @@ ### CLI ### Bundles +* Added `experimental.skip_artifacts_cleanup` flag ([#2980](https://github.com/databricks/cli/pull/2980)) ### API Changes From fda3b68a0e7d3f2ad71da88ddba5e626963b09a7 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 11:58:41 +0200 Subject: [PATCH 3/7] regenerated schema --- bundle/schema/jsonschema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 01b1144609..464d3e38b3 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -1717,6 +1717,7 @@ "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.Command" }, "skip_artifacts_cleanup": { + "description": "Determines whether to skip cleaning up the .internal folder", "$ref": "#/$defs/bool" }, "use_legacy_run_as": { From 3ca89d8e99324b3c249934b81e4e44d3c9d450c4 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 11:59:56 +0200 Subject: [PATCH 4/7] updated test output --- acceptance/bundle/paths/fallback_metric/output.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/acceptance/bundle/paths/fallback_metric/output.txt b/acceptance/bundle/paths/fallback_metric/output.txt index 9194d10c39..d76325bbd2 100644 --- a/acceptance/bundle/paths/fallback_metric/output.txt +++ b/acceptance/bundle/paths/fallback_metric/output.txt @@ -18,6 +18,10 @@ Deployment complete! "key": "presets_name_prefix_is_set", "value": false }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false @@ -44,6 +48,10 @@ Deployment complete! "key": "is_job_path_fallback", "value": true }, + { + "key": "skip_artifacts_cleanup", + "value": false + }, { "key": "python_wheel_wrapper_is_set", "value": false From e2dc0452f57cc4f8284cd555fbc2041db3dec6a7 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 12:44:13 +0200 Subject: [PATCH 5/7] still create folder --- .../artifacts/whl_no_cleanup/output.txt | 17 ++++++++++++++ .../bundle/artifacts/whl_no_cleanup/script | 3 +++ bundle/artifacts/upload.go | 23 +++++++++---------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/output.txt b/acceptance/bundle/artifacts/whl_no_cleanup/output.txt index b5b5136107..a78810dbca 100644 --- a/acceptance/bundle/artifacts/whl_no_cleanup/output.txt +++ b/acceptance/bundle/artifacts/whl_no_cleanup/output.txt @@ -25,3 +25,20 @@ Deployment complete! === No calls to delete internal folder expected >>> jq -s .[] | select(.path=="/api/2.0/workspace/delete") | select(.body.path | test(".*/artifacts/.internal")) out.requests.txt + +=== Expected 2 calls to create artifacts folder (because 2 deploys were done) +>>> jq -s .[] | select(.path=="/api/2.0/workspace/mkdirs") | select(.body.path | test(".*/artifacts/.internal")) out.requests.txt +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal" + } +} +{ + "method": "POST", + "path": "/api/2.0/workspace/mkdirs", + "body": { + "path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal" + } +} diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/script b/acceptance/bundle/artifacts/whl_no_cleanup/script index 718508ce1c..4536f92946 100644 --- a/acceptance/bundle/artifacts/whl_no_cleanup/script +++ b/acceptance/bundle/artifacts/whl_no_cleanup/script @@ -9,4 +9,7 @@ trace $CLI bundle deploy title "No calls to delete internal folder expected" trace jq -s '.[] | select(.path=="/api/2.0/workspace/delete") | select(.body.path | test(".*/artifacts/.internal"))' out.requests.txt +title "Expected 2 calls to create artifacts folder (because 2 deploys were done)" +trace jq -s '.[] | select(.path=="/api/2.0/workspace/mkdirs") | select(.body.path | test(".*/artifacts/.internal"))' out.requests.txt + rm out.requests.txt diff --git a/bundle/artifacts/upload.go b/bundle/artifacts/upload.go index 30a779aa39..8dcb8c006a 100644 --- a/bundle/artifacts/upload.go +++ b/bundle/artifacts/upload.go @@ -21,25 +21,24 @@ func (m *cleanUp) Name() string { } func (m *cleanUp) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { - skipArtifactsCleanup := b.Config.Experimental != nil && b.Config.Experimental.SkipArtifactsCleanup - b.Metrics.AddBoolValue("skip_artifacts_cleanup", skipArtifactsCleanup) - if skipArtifactsCleanup { - log.Info(ctx, "Skip cleaning up artifacts folder") - return nil - } - client, uploadPath, diags := libraries.GetFilerForLibrariesCleanup(ctx, b) if diags.HasError() { return diags } - // We intentionally ignore the error because it is not critical to the deployment - err := client.Delete(ctx, libraries.InternalDirName, filer.DeleteRecursively) - if err != nil { - log.Debugf(ctx, "failed to delete %s: %v", uploadPath, err) + skipArtifactsCleanup := b.Config.Experimental != nil && b.Config.Experimental.SkipArtifactsCleanup + b.Metrics.AddBoolValue("skip_artifacts_cleanup", skipArtifactsCleanup) + if skipArtifactsCleanup { + log.Info(ctx, "Skip cleaning up artifacts folder") + } else { + // We intentionally ignore the error because it is not critical to the deployment + err := client.Delete(ctx, libraries.InternalDirName, filer.DeleteRecursively) + if err != nil { + log.Debugf(ctx, "failed to delete %s: %v", uploadPath, err) + } } - err = client.Mkdir(ctx, libraries.InternalDirName) + err := client.Mkdir(ctx, libraries.InternalDirName) if err != nil { return diag.Errorf("unable to create directory for %s: %v", uploadPath, err) } From 3c4f820cf9442072b3b924c22d608b33bb284770 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 12:59:40 +0200 Subject: [PATCH 6/7] rename --- NEXT_CHANGELOG.md | 2 +- acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml | 2 +- acceptance/bundle/paths/fallback_metric/output.txt | 4 ++-- .../bundle/telemetry/deploy-artifact-path-type/output.txt | 4 ++-- acceptance/bundle/telemetry/deploy-compute-type/output.txt | 4 ++-- .../telemetry/deploy-config-file-count/out.telemetry.txt | 2 +- acceptance/bundle/telemetry/deploy-mode/output.txt | 4 ++-- .../bundle/telemetry/deploy-name-prefix/custom/output.txt | 2 +- .../deploy-name-prefix/mode-development/output.txt | 2 +- .../bundle/telemetry/deploy-no-uuid/out.telemetry.txt | 2 +- acceptance/bundle/telemetry/deploy-target-count/output.txt | 2 +- .../bundle/telemetry/deploy-variable-count/output.txt | 2 +- .../bundle/telemetry/deploy-whl-artifacts/databricks.yml | 6 +++--- acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt | 4 ++-- acceptance/bundle/telemetry/deploy/out.telemetry.txt | 2 +- bundle/artifacts/upload.go | 4 ++-- bundle/config/experimental.go | 4 ++-- bundle/internal/schema/annotations.yml | 2 +- bundle/schema/jsonschema.json | 4 ++-- 19 files changed, 29 insertions(+), 29 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index d8a95e94ea..e00cc76f29 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -9,6 +9,6 @@ ### CLI ### Bundles -* Added `experimental.skip_artifacts_cleanup` flag ([#2980](https://github.com/databricks/cli/pull/2980)) +* Added `experimental.skip_artifact_cleanup` flag ([#2980](https://github.com/databricks/cli/pull/2980)) ### API Changes diff --git a/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml b/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml index 302120b283..e6b0e4ddc7 100644 --- a/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml +++ b/acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml @@ -1,5 +1,5 @@ experimental: - skip_artifacts_cleanup: true + skip_artifact_cleanup: true resources: jobs: diff --git a/acceptance/bundle/paths/fallback_metric/output.txt b/acceptance/bundle/paths/fallback_metric/output.txt index d76325bbd2..77e41b7336 100644 --- a/acceptance/bundle/paths/fallback_metric/output.txt +++ b/acceptance/bundle/paths/fallback_metric/output.txt @@ -19,7 +19,7 @@ Deployment complete! "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { @@ -49,7 +49,7 @@ Deployment complete! "value": true }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt b/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt index 47c522c6c3..4de0de5f79 100644 --- a/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt +++ b/acceptance/bundle/telemetry/deploy-artifact-path-type/output.txt @@ -34,7 +34,7 @@ Deployment complete! "target_count": 2, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { @@ -82,7 +82,7 @@ Deployment complete! "target_count": 2, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-compute-type/output.txt b/acceptance/bundle/telemetry/deploy-compute-type/output.txt index 9f480b50e1..bb95771e28 100644 --- a/acceptance/bundle/telemetry/deploy-compute-type/output.txt +++ b/acceptance/bundle/telemetry/deploy-compute-type/output.txt @@ -18,7 +18,7 @@ Deployment complete! "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { @@ -44,7 +44,7 @@ Deployment complete! "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt b/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt index 7c0542d10b..3b06c63ebc 100644 --- a/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy-config-file-count/out.telemetry.txt @@ -34,7 +34,7 @@ "target_count": 1, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-mode/output.txt b/acceptance/bundle/telemetry/deploy-mode/output.txt index dbdacc5d7a..3b7c64559c 100644 --- a/acceptance/bundle/telemetry/deploy-mode/output.txt +++ b/acceptance/bundle/telemetry/deploy-mode/output.txt @@ -40,7 +40,7 @@ A common practice is to use a username or principal name in this path, i.e. use "target_count": 2, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { @@ -88,7 +88,7 @@ A common practice is to use a username or principal name in this path, i.e. use "target_count": 2, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt b/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt index f689c2f32f..60111dfe21 100644 --- a/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt +++ b/acceptance/bundle/telemetry/deploy-name-prefix/custom/output.txt @@ -34,7 +34,7 @@ Deployment complete! "value": true }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt b/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt index dd514ec03d..4e20c480e5 100644 --- a/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt +++ b/acceptance/bundle/telemetry/deploy-name-prefix/mode-development/output.txt @@ -34,7 +34,7 @@ Deployment complete! "value": true }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt b/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt index b678795f1b..2c288ea07b 100644 --- a/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy-no-uuid/out.telemetry.txt @@ -41,7 +41,7 @@ "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-target-count/output.txt b/acceptance/bundle/telemetry/deploy-target-count/output.txt index dd6a69ad0f..f3e2dcf3fc 100644 --- a/acceptance/bundle/telemetry/deploy-target-count/output.txt +++ b/acceptance/bundle/telemetry/deploy-target-count/output.txt @@ -29,7 +29,7 @@ Deployment complete! "target_count": 3, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-variable-count/output.txt b/acceptance/bundle/telemetry/deploy-variable-count/output.txt index fcd18efa37..2f7dea0a0d 100644 --- a/acceptance/bundle/telemetry/deploy-variable-count/output.txt +++ b/acceptance/bundle/telemetry/deploy-variable-count/output.txt @@ -29,7 +29,7 @@ Deployment complete! "target_count": 1, "bool_values": [ { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml b/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml index d60df6a930..8c4d2dca84 100644 --- a/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml +++ b/acceptance/bundle/telemetry/deploy-whl-artifacts/databricks.yml @@ -1,12 +1,12 @@ variables: wrapper: default: false - skip_artifacts_cleanup: + skip_artifact_cleanup: default: false experimental: python_wheel_wrapper: ${var.wrapper} - skip_artifacts_cleanup: ${var.skip_artifacts_cleanup} + skip_artifact_cleanup: ${var.skip_artifact_cleanup} targets: one: @@ -18,7 +18,7 @@ targets: two: variables: wrapper: true - skip_artifacts_cleanup: true + skip_artifact_cleanup: true artifacts: test: type: whl diff --git a/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt b/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt index 2d43b17f7b..eddd229c5f 100644 --- a/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt +++ b/acceptance/bundle/telemetry/deploy-whl-artifacts/output.txt @@ -46,7 +46,7 @@ Deployment complete! "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { @@ -106,7 +106,7 @@ Deployment complete! "value": true }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": true }, { diff --git a/acceptance/bundle/telemetry/deploy/out.telemetry.txt b/acceptance/bundle/telemetry/deploy/out.telemetry.txt index 9e38b05e62..05afbaafeb 100644 --- a/acceptance/bundle/telemetry/deploy/out.telemetry.txt +++ b/acceptance/bundle/telemetry/deploy/out.telemetry.txt @@ -47,7 +47,7 @@ "value": false }, { - "key": "skip_artifacts_cleanup", + "key": "skip_artifact_cleanup", "value": false }, { diff --git a/bundle/artifacts/upload.go b/bundle/artifacts/upload.go index 8dcb8c006a..341c1ee632 100644 --- a/bundle/artifacts/upload.go +++ b/bundle/artifacts/upload.go @@ -26,8 +26,8 @@ func (m *cleanUp) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics return diags } - skipArtifactsCleanup := b.Config.Experimental != nil && b.Config.Experimental.SkipArtifactsCleanup - b.Metrics.AddBoolValue("skip_artifacts_cleanup", skipArtifactsCleanup) + skipArtifactsCleanup := b.Config.Experimental != nil && b.Config.Experimental.SkipArtifactCleanup + b.Metrics.AddBoolValue("skip_artifact_cleanup", skipArtifactsCleanup) if skipArtifactsCleanup { log.Info(ctx, "Skip cleaning up artifacts folder") } else { diff --git a/bundle/config/experimental.go b/bundle/config/experimental.go index 181d52ac06..2381880e67 100644 --- a/bundle/config/experimental.go +++ b/bundle/config/experimental.go @@ -33,10 +33,10 @@ type Experimental struct { // Python configures loading of Python code defined with 'databricks-bundles' package. Python Python `json:"python,omitempty"` - // SkipArtifactsCleanup determines whether to skip cleaning up the .internal folder + // SkipArtifactCleanup determines whether to skip cleaning up the .internal folder // containing build artifacts such as wheels. When set to true, the .internal folder // and its contents will be preserved after bundle operations complete. - SkipArtifactsCleanup bool `json:"skip_artifacts_cleanup,omitempty"` + SkipArtifactCleanup bool `json:"skip_artifact_cleanup,omitempty"` } type Python struct { diff --git a/bundle/internal/schema/annotations.yml b/bundle/internal/schema/annotations.yml index 2906f15566..fcc0802cfc 100644 --- a/bundle/internal/schema/annotations.yml +++ b/bundle/internal/schema/annotations.yml @@ -75,7 +75,7 @@ github.com/databricks/cli/bundle/config.Experimental: "scripts": "description": |- The commands to run. - "skip_artifacts_cleanup": + "skip_artifact_cleanup": "description": |- Determines whether to skip cleaning up the .internal folder "use_legacy_run_as": diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 464d3e38b3..2a168b7259 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -1716,7 +1716,7 @@ "description": "The commands to run.", "$ref": "#/$defs/map/github.com/databricks/cli/bundle/config.Command" }, - "skip_artifacts_cleanup": { + "skip_artifact_cleanup": { "description": "Determines whether to skip cleaning up the .internal folder", "$ref": "#/$defs/bool" }, @@ -8601,4 +8601,4 @@ } }, "additionalProperties": {} -} \ No newline at end of file +} From d80111c0328814552bfc5df1871122e5a6b48546 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 3 Jun 2025 13:07:56 +0200 Subject: [PATCH 7/7] remove line --- bundle/schema/jsonschema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundle/schema/jsonschema.json b/bundle/schema/jsonschema.json index 2a168b7259..8640e402e1 100644 --- a/bundle/schema/jsonschema.json +++ b/bundle/schema/jsonschema.json @@ -8601,4 +8601,4 @@ } }, "additionalProperties": {} -} +} \ No newline at end of file