From fddfb6c13654d9fa838a6a5d6692f89f6a493c6c Mon Sep 17 00:00:00 2001 From: Andres Garcia Date: Thu, 22 Oct 2026 14:42:53 +0000 Subject: [PATCH 1/2] knowledge_base: add artifacts_dynamic_version_uv example Build a Python wheel with `uv build` and run it in a serverless python_wheel_task (environment_version 6). presets.artifacts_dynamic_version patches the wheel version on each deploy, so a redeploy without a version bump installs the new wheel. Commit uv.lock. Co-authored-by: Isaac Co-authored-by: omnigent --- .../artifacts_dynamic_version_uv/.gitignore | 2 + .../artifacts_dynamic_version_uv/README.md | 42 +++++++++++++++++++ .../databricks.yml | 30 +++++++++++++ .../pyproject.toml | 13 ++++++ .../resources/dynamic_version_job.job.yml | 17 ++++++++ .../src/dynamic_version_demo/__init__.py | 0 .../src/dynamic_version_demo/main.py | 12 ++++++ .../artifacts_dynamic_version_uv/uv.lock | 8 ++++ 8 files changed, 124 insertions(+) create mode 100644 knowledge_base/artifacts_dynamic_version_uv/.gitignore create mode 100644 knowledge_base/artifacts_dynamic_version_uv/README.md create mode 100644 knowledge_base/artifacts_dynamic_version_uv/databricks.yml create mode 100644 knowledge_base/artifacts_dynamic_version_uv/pyproject.toml create mode 100644 knowledge_base/artifacts_dynamic_version_uv/resources/dynamic_version_job.job.yml create mode 100644 knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/__init__.py create mode 100644 knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/main.py create mode 100644 knowledge_base/artifacts_dynamic_version_uv/uv.lock diff --git a/knowledge_base/artifacts_dynamic_version_uv/.gitignore b/knowledge_base/artifacts_dynamic_version_uv/.gitignore new file mode 100644 index 00000000..e32bcdd0 --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/.gitignore @@ -0,0 +1,2 @@ +.databricks +dist/ diff --git a/knowledge_base/artifacts_dynamic_version_uv/README.md b/knowledge_base/artifacts_dynamic_version_uv/README.md new file mode 100644 index 00000000..f1adfc0b --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/README.md @@ -0,0 +1,42 @@ +# Wheel with dynamic version and uv + +This Declarative Automation Bundles example builds a Python wheel with `uv build` and runs it in a serverless job. +The `presets.artifacts_dynamic_version` setting adds a build timestamp to the wheel version on each deploy. +Each deploy installs the new wheel, and you do not need to bump the version in `pyproject.toml`. + +For more information, see the [artifacts documentation](https://docs.databricks.com/aws/en/dev-tools/bundles/settings#artifacts). + +## Prerequisites + +* Databricks CLI v1.20.0 or above +* uv 0.10 or above (see [Installing uv](https://docs.astral.sh/uv/getting-started/installation/)) +* A workspace with serverless compute for jobs + +## Usage + +1. Deploy the bundle. The CLI builds the wheel with `uv build --wheel`: + ```bash + databricks bundle deploy + ``` +2. Run the job: + ```bash + databricks bundle run dynamic_version_job + ``` + The output shows the patched version and the marker: + ``` + dynamic_version_demo 0.1.0+: marker-v1 + ``` +3. Change `MARKER` in `src/dynamic_version_demo/main.py` to `marker-v2`. Keep `version = "0.1.0"` in `pyproject.toml`. +4. Deploy and run the job again: + ```bash + databricks bundle deploy + databricks bundle run dynamic_version_job + ``` + The output shows a new version suffix and the new marker: + ``` + dynamic_version_demo 0.1.0+: marker-v2 + ``` +5. Remove the deployed resources: + ```bash + databricks bundle destroy + ``` diff --git a/knowledge_base/artifacts_dynamic_version_uv/databricks.yml b/knowledge_base/artifacts_dynamic_version_uv/databricks.yml new file mode 100644 index 00000000..f8b0710c --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/databricks.yml @@ -0,0 +1,30 @@ +bundle: + name: artifacts_dynamic_version_uv + databricks_cli_version: ">= 1.20.0" + +include: + - resources/*.yml + +artifacts: + default: + type: whl + build: uv build --wheel + path: . + +# Append a build timestamp to the wheel version on each deploy. +# Clusters and serverless environments then install the new wheel without a version bump. +# To enable this for one artifact only, set `dynamic_version: true` on that artifact. +presets: + artifacts_dynamic_version: true + +targets: + dev: + default: true + mode: development + workspace: + root_path: /Workspace/bundle-examples/${bundle.name}/${bundle.target}/${workspace.current_user.short_name} + + prod: + mode: production + workspace: + root_path: /Workspace/bundle-examples/${bundle.name}/${bundle.target} diff --git a/knowledge_base/artifacts_dynamic_version_uv/pyproject.toml b/knowledge_base/artifacts_dynamic_version_uv/pyproject.toml new file mode 100644 index 00000000..d47f78c1 --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/pyproject.toml @@ -0,0 +1,13 @@ +[project] +name = "dynamic_version_demo" +# Keep this version fixed. The bundle adds a build timestamp on each deploy. +version = "0.1.0" +requires-python = ">=3.10" +dependencies = [] + +[project.scripts] +main = "dynamic_version_demo.main:main" + +[build-system] +requires = ["uv_build>=0.10.0,<0.11"] +build-backend = "uv_build" diff --git a/knowledge_base/artifacts_dynamic_version_uv/resources/dynamic_version_job.job.yml b/knowledge_base/artifacts_dynamic_version_uv/resources/dynamic_version_job.job.yml new file mode 100644 index 00000000..a1b83af6 --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/resources/dynamic_version_job.job.yml @@ -0,0 +1,17 @@ +resources: + jobs: + dynamic_version_job: + name: dynamic_version_job + tasks: + - task_key: main + environment_key: default + python_wheel_task: + package_name: dynamic_version_demo + entry_point: main + + environments: + - environment_key: default + spec: + environment_version: "6" + dependencies: + - ../dist/*.whl diff --git a/knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/__init__.py b/knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/main.py b/knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/main.py new file mode 100644 index 00000000..6c80f10b --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/src/dynamic_version_demo/main.py @@ -0,0 +1,12 @@ +from importlib.metadata import version + +# Change this value and deploy again. You do not need to bump the version. +MARKER = "marker-v1" + + +def main(): + print(f"dynamic_version_demo {version('dynamic_version_demo')}: {MARKER}") + + +if __name__ == "__main__": + main() diff --git a/knowledge_base/artifacts_dynamic_version_uv/uv.lock b/knowledge_base/artifacts_dynamic_version_uv/uv.lock new file mode 100644 index 00000000..16a80012 --- /dev/null +++ b/knowledge_base/artifacts_dynamic_version_uv/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 3 +requires-python = ">=3.10" + +[[package]] +name = "dynamic-version-demo" +version = "0.1.0" +source = { editable = "." } From 6562ef00ada1e9ddf910b62df5aa3b4dc1f65fc1 Mon Sep 17 00:00:00 2001 From: Andres Garcia Date: Thu, 22 Oct 2026 14:49:19 +0000 Subject: [PATCH 2/2] knowledge_base/artifacts_dynamic_version_uv: README wording per review Co-authored-by: Isaac Co-authored-by: omnigent --- knowledge_base/artifacts_dynamic_version_uv/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/knowledge_base/artifacts_dynamic_version_uv/README.md b/knowledge_base/artifacts_dynamic_version_uv/README.md index f1adfc0b..7536d215 100644 --- a/knowledge_base/artifacts_dynamic_version_uv/README.md +++ b/knowledge_base/artifacts_dynamic_version_uv/README.md @@ -2,7 +2,8 @@ This Declarative Automation Bundles example builds a Python wheel with `uv build` and runs it in a serverless job. The `presets.artifacts_dynamic_version` setting adds a build timestamp to the wheel version on each deploy. -Each deploy installs the new wheel, and you do not need to bump the version in `pyproject.toml`. +Each deploy installs the new wheel. +The base version in `pyproject.toml` stays `0.1.0`. For more information, see the [artifacts documentation](https://docs.databricks.com/aws/en/dev-tools/bundles/settings#artifacts).