Skip to content

Keep earlier patched wheels of the same distribution in artifacts.Build - #8027

Queued
denik wants to merge 1 commit into
mainfrom
denik/fix-patched-wheel-cleanup
Queued

denik wants to merge 1 commit into
mainfrom
denik/fix-patched-wheel-cleanup

Conversation

@denik

@denik denik commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Changes

artifacts.Build now empties each patched_wheels/<artifact>_<distribution> directory once per build, not before every file. Patched wheels left over from earlier builds are still removed.

Why

With dynamic_version: true, an artifact with several wheels of one package (for example different python or platform tags) kept only the last patched wheel. bundle deploy then failed with "unable to open ...: no such file or directory", after the remote .internal directory had already been cleaned. #8026 records this.

Tests

bundle/artifacts/whl_dynamic_same_distribution (from #8026) now deploys both patched wheels, and each job task references its own wheel. Its output is updated and the Badness is removed. It also gains a READPLAN variant (bundle plan followed by deploy --plan), so both deploy paths are pinned. That makes 4 variants of about 1.5s each. The test fails with the old build.go. The acceptance tests under bundle/artifacts, bundle/deploy/readplan and bundle/integration_whl pass locally, as do the bundle/artifacts and bundle/libraries unit tests.

Residual risks (pre-existing, not changed here)

  • Two different source wheels can map to the same patched file name. This takes the same package, the same version before any +local part, the same tags, and identical mtimes to the nanosecond (for example after cp -p). Then both files point at one patched wheel. Before this change the last source won; now the first one does. The remote upload path .internal/<basename> collides in the same way.
  • On case-insensitive filesystems, two artifacts whose names differ only in case share one directory and still clean it twice.
  • If deleting a stale file fails, the error is still only logged at info level.

This PR was created by analyzing coverage gaps.
Coverage: http://go/cli/dashboard/coverage/file/bundle/artifacts/build.go ((*build).Apply, lines 32-98, and makePatchedWheel, lines 129-161).

AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from f86d8a5 to e2a586d Compare November 26, 2026 00:26
@denik
denik force-pushed the denik/acc-record-patched-wheel-cleanup branch from b85d59d to fd5dd85 Compare November 26, 2026 00:31
@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from e2a586d to c89ecb5 Compare November 26, 2026 00:32
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 2d162792d | Workflow run

Selected 1 changed tests (limit=20, 0 not selected)

4 tests: regression=2 unreleased=0 coverage=2 failing=0
test branch main (5f99956) latest (v1.28.0)
TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=/READPLAN= ✅ ❌ ❌
TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=/READPLAN=1 ✅ ✅ ✅
TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=true/READPLAN= ✅ ❌ ❌
TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=true/READPLAN=1 ✅ ✅ ✅
TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=/READPLAN=: branch ✅ | main (5f99956) ❌ | latest (v1.28.0) ❌

main (5f99956):

acceptance_test.go:1402: Diff:
        --- bundle/artifacts/whl_dynamic_same_distribution/output.txt
        +++ /tmp/TestAcceptbundleartifactswhl_dynamic_same_distributionDMS=R3279643811/002/output.txt
        @@ -1,24 +1,6 @@
         Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl...
         Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl...
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Created jobs.test_job
        -Files: 5 uploaded, 0 deleted
        -Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
        +Error: unable to open [TEST_TMP_DIR]/.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl: no such file or directory
         
        -=== Each task references its own patched wheel
         
        ->>> print_requests.py //api/2.2/jobs/create
        -{
        -  "task_key": "TestTask",
        -  "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl"
        -}
        -{
        -  "task_key": "TestTask310",
        -  "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl"
        -}
        -
        -=== Both patched wheels are in the cache
        -
        ->>> find.py .databricks/.*whl
        -.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl
        -.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl
        +Exit code: 1
        
    acceptance_test.go:1180: LOG.plan:

latest (v1.28.0): same output as main (5f99956)

TestAccept/bundle/artifacts/whl_dynamic_same_distribution/DMS=true/READPLAN=: branch ✅ | main (5f99956) ❌ | latest (v1.28.0) ❌

main (5f99956):

acceptance_test.go:1402: Diff:
        --- bundle/artifacts/whl_dynamic_same_distribution/output.txt
        +++ /tmp/TestAcceptbundleartifactswhl_dynamic_same_distributionDMS=tr3242552531/002/output.txt
        @@ -1,24 +1,6 @@
         Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl...
         Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl...
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Created jobs.test_job
        -Files: 5 uploaded, 0 deleted
        -Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
        +Error: unable to open [TEST_TMP_DIR]/.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl: no such file or directory
         
        -=== Each task references its own patched wheel
         
        ->>> print_requests.py //api/2.2/jobs/create
        -{
        -  "task_key": "TestTask",
        -  "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl"
        -}
        -{
        -  "task_key": "TestTask310",
        -  "whl": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/artifacts/.internal/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl"
        -}
        -
        -=== Both patched wheels are in the cache
        -
        ->>> find.py .databricks/.*whl
        -.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl
        -.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py310-none-any.whl
        +Exit code: 1
        
    acceptance_test.go:1180: LOG.plan:

latest (v1.28.0): same output as main (5f99956)

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 2d16279

Run: 45767025570

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 279 20 4:22
💚​ aws-windows-latest-4core-16gb 1 281 18 3:31
💚​ azure linux-2core-8gb 1 278 20 4:03
💚​ azure-windows-latest-4core-16gb 1 280 18 3:23
💚​ gcp linux-2core-8gb 1 279 20 4:26
💚​ gcp-windows-latest-4core-16gb 1 281 18 3:26
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 5 slowest tests (at least 2 minutes):
duration env testname
3:30 aws-windows-latest-4core-16gb TestAccept
3:25 gcp-windows-latest-4core-16gb TestAccept
3:21 azure-windows-latest-4core-16gb TestAccept
2:01 gcp linux-2core-8gb TestAccept
2:00 aws linux-2core-8gb TestAccept

@denik
denik force-pushed the denik/acc-record-patched-wheel-cleanup branch from fd5dd85 to bbbecb0 Compare November 26, 2026 02:21
@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from c89ecb5 to 273d19b Compare November 26, 2026 02:21
@denik
denik marked this pull request as ready for review November 26, 2026 02:41
@denik
denik requested review from a team as code owners November 26, 2026 02:41

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at 273d19b. Each finding was verified against the code.

No blocking issues found.

This PR makes artifacts.Build empty each patched_wheels/<artifact>_<distribution> directory once per build, not once per file. That way several dynamic_version wheels of the same package all survive and get uploaded, and the acceptance test now covers both the plain and the --plan deploy paths. I traced the cleanedDirs map through Apply and makePatchedWheel. Wheels patched earlier in the same build are now kept, wheels left over from earlier builds are still removed, and the only caller always passes a non-nil map. I found nothing that should block the merge.

@denik
denik force-pushed the denik/acc-record-patched-wheel-cleanup branch from bbbecb0 to 9914af5 Compare November 26, 2026 03:14
@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from 273d19b to 683b714 Compare November 26, 2026 03:14

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Opus 5.5 + Claude Sonnet 5.5, cross-verified). Only points the reviewers agreed on are posted.

No issues found.

@denik
denik force-pushed the denik/acc-record-patched-wheel-cleanup branch from 9914af5 to 0123c10 Compare November 26, 2026 04:13
@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from 683b714 to 8fc731f Compare November 26, 2026 04:13

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Sonnet 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.

No issues found.

Base automatically changed from denik/acc-record-patched-wheel-cleanup to main November 26, 2026 05:23
makePatchedWheel emptied patched_wheels/<artifact>_<distribution> before
patching every file, so a dynamic_version artifact with two wheels of one
distribution (e.g. different python tags) lost all but the last patched
wheel and deploy failed to upload it. Empty each directory once per build.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik force-pushed the denik/fix-patched-wheel-cleanup branch from 8fc731f to 2d16279 Compare November 26, 2026 06:15
@github-actions github-actions Bot added the DABs DABs related issues label Nov 26, 2026
stevenayers pushed a commit to stevenayers/cli that referenced this pull request Nov 26, 2026
…ibution (databricks#8026)

## Changes
Adds the acceptance test
`bundle/artifacts/whl_dynamic_same_distribution`. It deploys a
`dynamic_version` wheel artifact with two wheels of the same package
that differ only in the python tag (`py3` and `py310`), each used by its
own job task. The output records how `bundle deploy` currently fails:

```
Error: unable to open [TEST_TMP_DIR]/.databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+1577836800000000000-py3-none-any.whl: no such file or directory
```

## Why
`makePatchedWheel` empties `patched_wheels/<artifact>_<distribution>`
before it patches each file. Both wheels share that directory, so
patching the second one deletes the first. The upload then fails. By
that point `artifacts.CleanUp` has already emptied the remote
`.internal` directory, so jobs from the previous deploy also lose their
wheel. Badness in test.toml says what is wrong and what is right. The
fix is stacked on top in
[databricks#8027](databricks#8027).

## Tests
This is a new small test. It runs in both DMS variants, inherited from
the bundle tests, with plain `bundle deploy`. Runtime is about 1.5s per
variant. Fixed UTC mtimes on the two copies keep the patched names
distinct and stable. The test prints the wheel each job task references
and the cache contents after the deploy. The fix in
[databricks#8027](databricks#8027) adds a `deploy
--plan` variant. It can't be recorded here: in the default sync mode,
`deploy --plan` re-patches missing wheels while it collects libraries,
which hides this bug.

I added a new test instead of extending one: no existing test has two
wheels of one package in one artifact, and adding the case to
`whl_dynamic` would run it once per variant of that test's 4-variant
matrix.

This PR was created by analyzing coverage gaps.
Coverage:
http://go/cli/dashboard/coverage/file/bundle/artifacts/build.go
(`makePatchedWheel`, lines 129-161).

AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik added this pull request to the merge queue Nov 26, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues factory-generated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants