environments setup-local: consolidate databricks-connect to a single managed pin - #6255
environments setup-local: consolidate databricks-connect to a single managed pin#6255rugpanov wants to merge 4 commits into
Conversation
403aed4 to
d528701
Compare
Integration test reportCommit: 1deddf8
8 interesting tests: 4 RECOVERED, 4 SKIP
Top 6 slowest tests (at least 2 minutes):
|
|
Reviewed the whole change and probed it locally (built both branches, ran the package tests, and fuzzed My concerns are about the policy the PR adopts, not the parsing. 1. Deleting from
|
anton-107
left a comment
There was a problem hiding this comment.
Requesting changes based on my detailed review above. Two blockers before this can land:
- Unconditional removal from
[project].dependencies. The pin is deleted even when it co-resolves fine with the env pin (e.g.>=15vs~=17.2.0), and even when it's marker-gated. Because the default template builds a wheel from this file (uv build --wheel+ hatchling), this silently drops a runtime dependency from the shipped artifact's install-requires metadata — nothing in the localuv syncsurfaces it. Please gate the removal onrangesDisjoint, or keep[project].dependenciesout of scope and leave it toW_DBCONNECT_PIN_DUPLICATED. - Silent deletion of an env-identical pin in
[project].dependencies(no warning at all). The "pure deduplication" reasoning holds for a second dev-array element, not for the only declaration in another table.
The ==X.* wildcard work and the planDBConnect refactor are clean and I'd keep them as-is. This is a scope decision, not a rewrite. Also please rebase — setup-local shipped in v1.12.0, so the "not yet released, no changelog" rationale is stale and a .nextchanges/cli/ fragment is now warranted.
…managed pin setup-local managed databricks-connect only in [dependency-groups].dev, so a databricks-connect requirement shipped by a template in [project].dependencies conflicted with the managed dev pin and left the project unresolvable — `uv sync` failed with an unsatisfiable-resolution error. In the install flow, databricks-connect is now fully owned by setup-local: after the managed pin lands in the dev group, every other databricks-connect pin is removed from [project].dependencies, each [project.optional-dependencies] extra, and every dependency group, so exactly one requirement survives. Each removed pin is surfaced with the new W_DBCONNECT_CONSOLIDATED warning. --constraints-only leaves databricks-connect untouched. parseClause now also models ==X.* prefix-match wildcards so a conflict between a wildcard user pin and the environment's constraint-dependencies is reported instead of silently missed. Co-authored-by: Isaac
…log fragment Code review found that consolidation could silently delete an inline comment that belonged to a surviving element: splitTopLevelElements groups the text after a comma into the next element's token, so a trailing comment on the element before a removed databricks-connect pin was dropped with it, violating MergeManaged's comment-preservation contract. removeDbconnectFromArraySpan now carries those leading comment lines onto the next retained token so they stay on their line. Also drop the .nextchanges fragment: environments setup-local is still unreleased (its own fragment is pending), so this fix lands in the same release that introduces the command — a separate changelog entry would be redundant. Co-authored-by: Isaac
…flict Per maintainer review, gate the consolidation removal on rangesDisjoint: a stray databricks-connect pin is deleted only when its version range provably cannot co-resolve with the managed pin. A pin that overlaps it (databricks-connect>=15 vs ~=17.2.0), carries no version, is marker-gated, or already equals the managed pin is left in place — so the merge no longer silently rewrites a user's declaration that isn't broken, including [project].dependencies, which the default template compiles into the built wheel's metadata. This also removes the special-case silent deletion of an env-equal pin (an equal pin is never disjoint, so it is simply kept). Other review fixes: preserve the array's trailing comma and the closing bracket's own line when removing the last element of a multi-line array; broaden the W_DBCONNECT_PIN_DUPLICATED / W_DBCONNECT_CONSOLIDATED doc prose to name the class of unreachable spellings rather than one example; note the dotted-key handling in arrayKeyRe; use cmp.Compare for the span sort. Add unit + acceptance coverage for compatible/marker/unversioned pins being kept. setup-local shipped in v1.12.0, so this user-visible behavior change now carries a .nextchanges/cli/ fragment (branch rebased onto main). Co-authored-by: Isaac
d528701 to
15a3910
Compare
- singleClauseRe: note ==X.Y.* wildcards are now modeled by parseClause. - warnings_test matching case: an env-equal stray is kept by the gate, not removed. - dbconnect-consolidate-check script: pins here are disjoint (hence removed); warnings are in document order, not resolution order. Co-authored-by: Isaac
|
Thanks for the thorough review and the fuzzing — really helpful. All addressed in the latest push (rebased on 1 (removal scope) + 2 (env-equal, silent): Gated every removal on
This means 3 (formatting): Removing the last element of a multi-line array now keeps 4 (doc): Broadened the 5 (changelog): You're right — Smaller notes: added the The |
anton-107
left a comment
There was a problem hiding this comment.
Re-reviewed the three new commits. This addresses everything I raised — verified by building the branch, re-running my probes on the exact cases I flagged, re-fuzzing the consolidation over 6000 randomized array shapes (0 invalid-TOML / 0 non-idempotent), and running the full localenv acceptance suite (61 pass). Clearing my changes-requested.
Blocker 1 — unconditional removal from [project].dependencies: fixed. The removal is now gated on dbconnectPinConflicts → rangesDisjoint. Confirmed each case behaves correctly with env pin ~=17.2.0:
databricks-connect>=15→ kept (co-resolves at 17.2.x)- bare
databricks-connect(no version) → kept databricks-connect>=15 ; python_version < '3.13'(marker-gated) → keptdatabricks-connect==15.1.*(disjoint) → removed, which is the actual bug- mixed disjoint+overlapping in one array → only the disjoint one goes
The new dbconnect-compatible-kept-check acceptance test covers all three location types (project.dependencies, an optional extra, a sibling group) with compatible/marker/unversioned pins, and asserts no W_DBCONNECT_CONSOLIDATED fires. That's exactly the coverage gap I noted.
Blocker 2 — silent deletion of an env-equal pin: fixed. The special-case continue in dbconnectWarnings is gone, and since an equal pin is never disjoint the gate keeps it entirely — dependencies = ["databricks-connect~=17.2.0"] is now left in place, not silently dropped. Cleaner than warning-on-delete.
Formatting (nit 3): fixed. The trailing-comma / bracket-line restore in removeDbconnectFromArraySpan works — multi-line arrays with the dbc pin last (with or without a trailing comma) now keep ] on its own line and preserve the magic trailing comma. The carry comment-relocation is unchanged and still acceptable.
Doc-comment nits (4): fixed. W_DBCONNECT_PIN_DUPLICATED / W_DBCONNECT_CONSOLIDATED prose now names the class of unreachable spellings; singleClauseRe notes the wildcard; arrayKeyRe documents the dotted-key skip; span sort uses cmp.Compare.
Changelog (5): fixed. Rebased onto main and a .nextchanges/cli/ fragment added, correctly scoped to the conflict-only behavior.
One thing worth a sanity check (not blocking): the consolidation and the duplicate-survivor detection now use two different comparison entry points — dbconnectPinConflicts for what gets deleted, and the existing rangesDisjoint path in the survivor loop for what gets flagged. Both bottom out in rangesDisjoint, so they agree, but they're separate call sites; a future change to one should keep the other in step. The interplay is currently correct — I verified a disjoint single-quoted pin (unreachable by the line-based removal) is still surfaced as W_DBCONNECT_PIN_DUPLICATED, an overlapping unreachable pin stays silent, and a removed-in-docs + duplicated-in-qa case reports both.
Nice work on the turnaround. Approving.
Problem
databricks environments setup-localmanageddatabricks-connectonly inside[dependency-groups].dev. When a project (e.g. one generated from the data-engineering template) also pinsdatabricks-connectin[project].dependencies, setup-local set the dev pin to the compute-matched version but left the[project].dependenciespin untouched. uv then had to co-install two disjoint requirements (==15.1.*and>=16.0,<17) and failed with a cryptic unsatisfiable-resolution dump at theprovisionphase. A warning meant to catch this never fired (it couldn't parse==X.*wildcards), and warnings are advisory anyway.Change
In the install flow, after the managed pin lands in
[dependency-groups].dev, the merge removes any conflictingdatabricks-connectpin elsewhere — in[project].dependencies, an optional-dependency extra, or another dependency group. "Conflicting" means the pin's version range provably cannot co-resolve with the managed pin (rangesDisjoint); that is exactly the pin that would makeuv syncunsatisfiable. A pin that co-resolves (databricks-connect>=15vs~=17.2.0), carries no version, is marker-gated, or already equals the managed version is left in place — so a user declaration that isn't broken is never rewritten, including[project].dependencies, which the default template compiles into the built wheel's metadata. Each removed pin is surfaced with the newW_DBCONNECT_CONSOLIDATEDwarning.--constraints-onlymode leavesdatabricks-connectcompletely untouched.parseClausenow models PEP 440==X.*prefix-match wildcards, so a conflict between a wildcard user pin and the environment'sconstraint-dependenciesis reported (W_USER_CONSTRAINT_CONFLICT) rather than silently missed.The removal preserves the file's other bytes: a neighbouring comment is kept, and removing the last element of a multi-line array keeps the closing
]on its own line and preserves the trailing comma. The line-based removal matches the same shapes the rewrite does (double-quoted elements under bare-key arrays); rarer spellings it can't reach — single-quoted pins, quoted TOML keys, inline-table/dotted sub-table forms — are left in place and surfaced asW_DBCONNECT_PIN_DUPLICATEDwhen disjoint.Testing
libs/localenv/merge_test.go,warnings_test.go): disjoint pins removed across all three location types; compatible / unversioned / marker-gated / env-equal pins kept; empty-array, trailing-comma, and closing-bracket handling; comment preservation;==X.*wildcard disjoint math.merge-warnings/merge-warnings-json/dbconnect-consolidate-check; addedconstraints-only-existing,wildcard-constraint-conflict-check, anddbconnect-compatible-kept-check(the "kept" behavior).uv syncresolves cleanly.This pull request and its description were written by Isaac.