-
Notifications
You must be signed in to change notification settings - Fork 93
Switch default-python to use pyproject.toml & uv & dynamic_version in dev [hatchling backend] #3042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
84838b2
to
739f980
Compare
a9fc9e8
to
ecd0eae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modernizes the default‐python template by removing setup.py
and in‐code versioning in favor of a pyproject.toml
‐based hatchling build, switches the bundle to use uv build --wheel
, and applies dynamic_version
only on non‐serverless dev targets.
- Drop
__version__
andsetup.py.tmpl
, introducepyproject.toml.tmpl
with hatchling wheel config. - Update
databricks.yml.tmpl
to runuv build --wheel
and conditionally enabledynamic_version
for dev. - Refresh acceptance tests (
out.*
,check_output.py
) and updateNEXT_CHANGELOG.md
.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
libs/template/.../init.py | Remove hardcoded __version__ assignment |
libs/template/.../pyproject.toml.tmpl | Add [project] metadata and hatchling wheel build config |
libs/template/.../databricks.yml.tmpl | Use uv build --wheel and conditional dynamic_version in dev |
acceptance/.../check_output.py | Replace literal upload check with regex-based UPLOADING_WHL |
NEXT_CHANGELOG.md | Document new default-python template changes |
Comments suppressed due to low confidence (2)
NEXT_CHANGELOG.md:6
- [nitpick] The backslash in
dynamic\_version
is only needed to escape Markdown italics. For clarity, wrap it in inline code:dynamic_version
.
* Switch default-python template to use pyproject.toml + dynamic\_version in dev target. uv is now required. ([#3042](https://github.com/databricks/cli/pull/3042))
libs/template/templates/default-python/template/{{.project_name}}/databricks.yml.tmpl:8
- The conditional
artifacts:
block under thedev
target may be misaligned in indentation and could break YAML parsing. Align theartifacts:
andpython_artifact:
keys with theworkspace:
block underdev
.
{{ if $with_python }}
import subprocess | ||
|
||
CLOUD_ENV = os.environ.get("CLOUD_ENV") | ||
if CLOUD_ENV and os.environ["SERVERLESS"] == "yes" and not os.environ.get("TEST_METASTORE_ID"): | ||
sys.exit(f"SKIP_TEST SERVERLESS=yes but TEST_METASTORE_ID is empty in this env {CLOUD_ENV=}") | ||
|
||
BUILDING = "Building python_artifact" | ||
UPLOADING = "Uploading dist/" | ||
UPLOADING_WHL = re.compile("Uploading .*whl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In is_printable_line
, using UPLOADING_WHL.match(line)
only matches at the start and will miss indented or prefixed upload lines. Consider using search()
in both the function and the regex (e.g., re.compile("Uploading .*\.whl")
) or anchoring appropriately.
UPLOADING_WHL = re.compile("Uploading .*whl") | |
UPLOADING_WHL = re.compile(r"Uploading .*\.whl") |
Copilot uses AI. Check for mistakes.
acceptance/bundle/templates/default-python/serverless/output/my_default_python/pyproject.toml
Show resolved
Hide resolved
63a504d
to
039c825
Compare
039c825
to
206342e
Compare
77d07fa
to
76ac9fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
libs/template/templates/default-python/template/{{.project_name}}/databricks.yml.tmpl
Outdated
Show resolved
Hide resolved
libs/template/templates/default-python/template/{{.project_name}}/pyproject.toml.tmpl
Outdated
Show resolved
Hide resolved
libs/template/templates/default-python/template/{{.project_name}}/pyproject.toml.tmpl
Show resolved
Hide resolved
Do we need an additional level of indirection where we enable artifacts_dynamic_version in some templates but not the other? I think we should have it enabled across the board, or even consider making it a default in dev mode. We should also enable in jobs-as-code-template because it currently uses a workaround with timestamps. What about using the setuptools backend? I think it's more adopted because it's the default. |
It has downsides -with new files created for each deploy you either delete them and potentially break old runs or keep them and potentially accumulate too many. You also accumulate them on cluster. It is still worth it, but it needs to be targeted only to cases where it does help. Serverless does not have stale version problem, so no need to enable it there.
hatchling is default in uv: https://docs.astral.sh/uv/concepts/build-backend/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to unblock merge.
Before we merge though, we need to ensure this is compatible with DABs in the workspace.
@@ -18,7 +25,14 @@ targets: | |||
default: true | |||
workspace: | |||
host: {{workspace_host}} | |||
|
|||
{{ if ($with_classic) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You comment:
Serverless does not have stale version problem, so no need to enable it there.
If some cache is enabled again it might break. We can opt to be defensive and include it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Native solution seem preferable, given the downsides (new wheel name may cause jobs not to find old wheel names OR all wheels are kept, polluting the workspace).
We have a test that monitors serverless behaviour without dynamic_version.
27a36eb
to
9e8ba1f
Compare
…ot of dependencies, slows down "uv sync" ├── databricks-dlt v0.3.0 (extra: dev) │ └── databricks-connect v15.4.9 │ ├── databricks-sdk v0.57.0 │ │ ├── google-auth v2.40.3 │ │ │ ├── cachetools v5.5.2 │ │ │ ├── pyasn1-modules v0.4.2 │ │ │ │ └── pyasn1 v0.6.1 │ │ │ └── rsa v4.9.1 │ │ │ └── pyasn1 v0.6.1 │ │ └── requests v2.32.4 │ │ ├── certifi v2025.6.15 │ │ ├── charset-normalizer v3.4.2 │ │ ├── idna v3.10 │ │ └── urllib3 v2.4.0 │ ├── googleapis-common-protos v1.70.0 │ │ └── protobuf v6.31.1 │ ├── grpcio v1.73.0 │ ├── grpcio-status v1.73.0 │ │ ├── googleapis-common-protos v1.70.0 (*) │ │ ├── grpcio v1.73.0 │ │ └── protobuf v6.31.1 │ ├── numpy v1.26.4 │ ├── packaging v25.0 │ ├── pandas v2.3.0 │ │ ├── numpy v1.26.4 │ │ ├── python-dateutil v2.9.0.post0 │ │ │ └── six v1.17.0 │ │ ├── pytz v2025.2 │ │ └── tzdata v2025.2 │ ├── py4j v0.10.9.7 │ ├── pyarrow v20.0.0 │ ├── setuptools v80.9.0 │ └── six v1.17.0
9e8ba1f
to
c982940
Compare
Changes
Why
Modern Python is based around pyproject.toml, not setup.py.
Using DAB-provided dynamic_version attribute allows keeping pyproject.toml simple and does not constraint what build backend users can choose.
Note, I've also considered using uv_build backend #3004 but it seems too early at the moment and hatchling is better tested with DABs.
Tests
Existing tests.