Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions knowledge_base/artifacts_dynamic_version_uv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.databricks
dist/
43 changes: 43 additions & 0 deletions knowledge_base/artifacts_dynamic_version_uv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.
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).

## 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+<timestamp>: 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+<timestamp>: marker-v2
```
5. Remove the deployed resources:
```bash
databricks bundle destroy
```
30 changes: 30 additions & 0 deletions knowledge_base/artifacts_dynamic_version_uv/databricks.yml
Original file line number Diff line number Diff line change
@@ -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}
13 changes: 13 additions & 0 deletions knowledge_base/artifacts_dynamic_version_uv/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 8 additions & 0 deletions knowledge_base/artifacts_dynamic_version_uv/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.