Skip to content

Keep python_wheel_wrapper notebooks in the state pushed by bundle deploy --plan - #8067

Open
denik wants to merge 8 commits into
mainfrom
denik/readplan-keep-wrapper-in-state
Open

denik wants to merge 8 commits into
mainfrom
denik/readplan-keep-wrapper-in-state

Conversation

@denik

@denik denik commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Changes

  • New deploy.StateUpdateForSavedPlan(), used by phases.Deploy when it applies a saved plan (bundle deploy --plan, and apps deploy with a saved plan). It keeps the previous deployment state's entries under <target>/.internal/ that the synced files don't list, unless a synced file has the same remote name (for example x.ipynb next to a kept x.py) or this run's file sync deleted them. Plain deploys keep using StateUpdate() unchanged.
  • libs/sync: Sync.Deleted() returns the remote names the last run deleted (next to FileCounts()); files.Upload stores them in b.DeletedFiles. Without it, planning and applying in one checkout after a wrapper is no longer needed would re-list the wrapper the apply just deleted, and every later apply would report deleting it again.
  • withoutInternalFiles becomes splitInternalFiles, which returns both halves, so the pull and the update share one matcher.
  • bundle/deploy/readplan/fresh-checkout-wheel-wrapper: the pushed state now lists the wrapper notebook after every apply. New steps: a second apply in the same checkout with its cache kept but no wrapper on disk (plan saved in another directory), a plain deploy from a fresh checkout with python_wheel_wrapper disabled, which deletes the wrapper (Files: 1 uploaded, 1 deleted), and plan-and-apply in one checkout after the wrapper is no longer needed (the apply deletes it, the state drops it, the next apply deletes nothing). Badness removed.

Why

Since #7988, applying a saved plan from a fresh checkout keeps the remote python_wheel_wrapper notebooks, because the plan skips the build that writes them and the plan's jobs still run them. But the state file list is built from the local synced files only, so the pushed deployment.json dropped the wrapper, and no later deploy could delete it. #7988 listed this under residual risks.

Badness note:

Applying a saved plan from a fresh checkout skips the build that generates the python_wheel_wrapper notebook, so the deployment state that bundle deploy --plan pushes lists only databricks.yml, not the wrapper notebook the job still runs (.internal/notebook_3_whl_test_task). A file the state does not list is never deleted by later deploys. The state should list the wrapper notebook, as a plain bundle deploy does.

Before:

>>> [CLI] workspace export .../state/deployment.json
json.files[0].local_path = "databricks.yml";

After:

>>> [CLI] workspace export .../state/deployment.json
json.files[0].local_path = "databricks.yml";
json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";

Other build-generated files: the wrapper notebooks are the only build outputs under the synced .internal directory. Built artifacts (wheels, patched wheels) are uploaded as libraries and are not in the state's file list. Synced outputs of build hooks are deleted on apply by design (#7988).

Tests

  • Acceptance: bundle/deploy/readplan/fresh-checkout-wheel-wrapper (both DMS variants). With phases.Deploy using plain StateUpdate() for saved plans, the three state listings lose the wrapper and the plain deploy leaves it behind (Files: 1 uploaded, 0 deleted, the notebook is still listed). With the deleted-name filter removed, the plan-and-apply step's state still lists the deleted wrapper.
  • Unit: TestSplitInternalFiles (renamed from TestWithoutInternalFiles, also checks the internal half) and TestStateUpdateForSavedPlanKeepsInternalFiles (plain vs saved plan; the internal entry is kept, a removed file is dropped, a re-synced file is listed once, an entry the sync deleted is dropped).
  • TestAccept/bundle/{deploy,python_wheel,artifacts,sync}, TestAccept/{apps,pipelines,sync}, the READPLAN=1 runs of the bundle and apps sets, and the bundle, libs/sync and cmd/sync unit tests pass locally.

Gaps and risks

  • Applying a saved plan still doesn't regenerate wrappers (the build is skipped), so an apply never deletes one. A wrapper no task needs any more stays in the workspace, listed in the state, until a deploy restores the state from the workspace: a plain deploy from a fresh checkout, or any deploy after another checkout's deploy. A pipeline that only ever applies saved plans keeps such wrappers indefinitely.
  • A plain deploy in the same cache directory as a fresh-checkout apply uses the local sync snapshot, which doesn't list the kept wrapper (the apply restored it without that entry), so it doesn't delete the wrapper and drops it from the state. That was already the case before this PR. Closing it needs the sync snapshot to keep such entries (a libs/sync change) or regenerating wrappers on apply; both are left for a follow-up.
  • Entries are kept by path, from the previous state the apply loads. An entry can stay listed although the wrapper is gone when the local state predates a bundle destroy in that checkout, or when the sync deleted the wrapper but writing the local state then failed and the apply is retried. Such an entry only makes a later deploy delete a missing path under the CLI's .internal directory, which is ignored.
  • The restored file list applies to the current workspace.file_path even if it changed since the last deploy (already listed in Pull deployment state in bundle deploy --plan #7988).
  • Not run on cloud: the test is Cloud = false; the change only affects which entries go into the state file, and the testserver serves that file like any workspace file.
  • Risk: low.

Dashboard

TestAccept/bundle/deploy/readplan/fresh-checkout-wheel-wrapper (Badness note only, no CI failure).

This PR fixes behavior recorded as Badness in acceptance tests.

🤖 AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

@github-actions github-actions Bot added the DABs DABs related issues label Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: e350cab20 | Workflow run

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

2 tests: regression=2 unreleased=0 coverage=0 failing=0
test branch main (9a14ad6) latest (v1.28.0)
TestAccept/bundle/deploy/readplan/fresh-checkout-wheel-wrapper/DMS= ✅ ❌ ❌
TestAccept/bundle/deploy/readplan/fresh-checkout-wheel-wrapper/DMS=true ✅ ❌ ❌
TestAccept/bundle/deploy/readplan/fresh-checkout-wheel-wrapper/DMS=: branch ✅ | main (9a14ad6) ❌ | latest (v1.28.0) ❌

main (9a14ad6):

acceptance_test.go:1402: Diff:
        --- bundle/deploy/readplan/fresh-checkout-wheel-wrapper/output.txt
        +++ /tmp/TestAcceptbundledeployreadplanfresh-checkout-wheel-wrapperD1770664620/002/output.txt
        @@ -34,7 +34,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply again in the same checkout, which keeps its cache but has no wrapper on disk (plan saved in another checkout)
         
        @@ -53,7 +52,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply from a fresh checkout whose cache directory (DATABRICKS_BUNDLE_TMP) is outside the bundle
         
        @@ -79,7 +77,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === A later plain deploy from a fresh checkout deletes the wrapper once the task no longer needs it
         
        @@ -90,46 +87,13 @@
         >>> [CLI] bundle deploy
         Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
         Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        +Files: 1 uploaded, 0 deleted
         Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        +ID                Type      Language  Path
        +4000000000000074  NOTEBOOK  PYTHON    /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal/notebook_3_whl_test_task
         
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        +Unexpected success
         
        -=== Plan and apply in one checkout after the wrapper is no longer needed: the apply deletes it and the state drops it
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: false python_wheel_wrapper: true
        -
        ->>> [CLI] bundle deploy
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 2 uploaded, 0 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: true python_wheel_wrapper: false
        -
        ->>> rm -rf .databricks
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Files: 0 uploaded, 0 deleted
        -Resources: 0 created, 0 changed, 0 deleted, 1 unchanged
        +Exit code: 1

latest (v1.28.0): same output as main (9a14ad6)

TestAccept/bundle/deploy/readplan/fresh-checkout-wheel-wrapper/DMS=true: branch ✅ | main (9a14ad6) ❌ | latest (v1.28.0) ❌

main (9a14ad6):

acceptance_test.go:1402: Diff:
        --- bundle/deploy/readplan/fresh-checkout-wheel-wrapper/output.txt
        +++ /tmp/TestAcceptbundledeployreadplanfresh-checkout-wheel-wrapperD1693722458/002/output.txt
        @@ -34,7 +34,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply again in the same checkout, which keeps its cache but has no wrapper on disk (plan saved in another checkout)
         
        @@ -53,7 +52,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply from a fresh checkout whose cache directory (DATABRICKS_BUNDLE_TMP) is outside the bundle
         
        @@ -79,7 +77,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === A later plain deploy from a fresh checkout deletes the wrapper once the task no longer needs it
         
        @@ -90,46 +87,13 @@
         >>> [CLI] bundle deploy
         Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
         Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        +Files: 1 uploaded, 0 deleted
         Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        +ID                Type      Language  Path
        +4000000000000080  NOTEBOOK  PYTHON    /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal/notebook_3_whl_test_task
         
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        +Unexpected success
         
        -=== Plan and apply in one checkout after the wrapper is no longer needed: the apply deletes it and the state drops it
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: false python_wheel_wrapper: true
        -
        ->>> [CLI] bundle deploy
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 2 uploaded, 0 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: true python_wheel_wrapper: false
        -
        ->>> rm -rf .databricks
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Files: 0 uploaded, 0 deleted
        -Resources: 0 created, 0 changed, 0 deleted, 1 unchanged
        +Exit code: 1
        
FAIL

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- bundle/deploy/readplan/fresh-checkout-wheel-wrapper/output.txt
        +++ /tmp/TestAcceptbundledeployreadplanfresh-checkout-wheel-wrapperD1947874752/002/output.txt
        @@ -34,7 +34,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply again in the same checkout, which keeps its cache but has no wrapper on disk (plan saved in another checkout)
         
        @@ -53,7 +52,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === Apply from a fresh checkout whose cache directory (DATABRICKS_BUNDLE_TMP) is outside the bundle
         
        @@ -79,7 +77,6 @@
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
         json.files[0].local_path = "databricks.yml";
        -json.files[1].local_path = ".databricks/bundle/default/.internal/notebook_3_whl_test_task.py";
         
         === A later plain deploy from a fresh checkout deletes the wrapper once the task no longer needs it
         
        @@ -90,46 +87,13 @@
         >>> [CLI] bundle deploy
         Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
         Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        +Files: 1 uploaded, 0 deleted
         Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
         
         >>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        +ID                Type      Language  Path
        +4000000000000086  NOTEBOOK  PYTHON    /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal/notebook_3_whl_test_task
         
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        +Unexpected success
         
        -=== Plan and apply in one checkout after the wrapper is no longer needed: the apply deletes it and the state drops it
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: false python_wheel_wrapper: true
        -
        ->>> [CLI] bundle deploy
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 2 uploaded, 0 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> update_file.py databricks.yml python_wheel_wrapper: true python_wheel_wrapper: false
        -
        ->>> rm -rf .databricks
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Updated jobs.whl
        -Files: 1 uploaded, 1 deleted
        -Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace list /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal
        -Error: Path (/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files/.databricks/bundle/default/.internal) doesn't exist.
        -
        ->>> MSYS_NO_PATHCONV=1 [CLI] workspace export /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/deployment.json
        -json.files[0].local_path = "databricks.yml";
        -
        ->>> [CLI] bundle plan -o json
        -
        ->>> [CLI] bundle deploy --plan tmp.plan.json
        -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
        -Files: 0 uploaded, 0 deleted
        -Resources: 0 created, 0 changed, 0 deleted, 1 unchanged
        +Exit code: 1
        
FAIL

@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: e350cab

Run: 46397383822

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 173 18 2:19
💚​ aws-windows-latest-4core-16gb 1 173 18 2:54
💚​ azure linux-2core-8gb 1 172 18 2:26
💚​ azure-windows-latest-4core-16gb 1 172 18 3:03
💚​ gcp linux-2core-8gb 1 173 18 2:24
💚​ gcp-windows-latest-4core-16gb 1 173 18 3:10
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 3 slowest tests (at least 2 minutes):
duration env testname
3:09 gcp-windows-latest-4core-16gb TestAccept
3:02 azure-windows-latest-4core-16gb TestAccept
2:52 aws-windows-latest-4core-16gb TestAccept

@denik
denik marked this pull request as ready for review November 26, 2026 16:53
@denik
denik requested review from a team as code owners November 26, 2026 16:53

@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 b7d2088. Each finding was verified against the code.

No blocking issues found. 4 non-blocking comment(s) below.

This PR makes bundle deploy --plan keep the previous state's <target>/.internal/ entries (the python_wheel_wrapper notebooks) in the pushed deployment state, and drops the ones this run's sync deleted. A new Sync.Deleted() reports those deletions. The main path is correct and the acceptance test covers the important flows. What's left: withKeptFiles dedups by local path when it should dedup by remote name, so it can write a state the next fresh-checkout deploy can't load. There are also gaps in the unit test and a small inaccuracy in the new deleted field comment.

Comment thread bundle/deploy/state_update.go Resolved
Comment thread bundle/deploy/state_update_test.go Resolved
Comment thread bundle/deploy/state_update_test.go Resolved
Comment thread libs/sync/sync.go Resolved

@andrewnester andrewnester 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.

Holding my approval until the open thread on bundle/deploy/state_update_test.go is settled.

@denik
denik requested a review from andrewnester November 26, 2026 17:46
@denik

denik commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/review

@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 49a5e87. Each finding was verified against the code.

Not ready yet: 1 blocking issue(s), tagged [blocking].

This PR makes bundle deploy --plan keep the previous state's <target>/.internal entries, such as python_wheel_wrapper notebooks, in the pushed deployment.json. It does this through StateUpdateForSavedPlan, withKeptFiles and a new Sync.Deleted(). The approach works for the wrapper cases the acceptance test covers, but withKeptFiles only dedupes by remote name. If a matching file stops being a notebook, the state lists the same local path twice, and every later deploy from a fresh checkout fails to load the snapshot. There is also one imprecise doc comment.

Questions

  1. File.remoteName repeats the rule from libs/sync newSnapshotStateFrom (strip the extension for notebooks) in bundle/deploy, and the taken check depends on the two staying identical. Could libs/sync export the helper, or report the remote names it tracks next to Deleted(), so the rule lives in one place? Or is the copy acceptable here? (non-blocking)

for _, f := range kept {
// States written by CLI versions <= v0.220.0 on Windows use backslashes.
f.LocalPath = filepath.ToSlash(f.LocalPath)
if !taken[f.remoteName()] {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[blocking] withKeptFiles only checks remote names, but NewSnapshotState also rejects duplicate local paths (libs/sync/snapshot_state.go:56). Take target dev and src/dev/.internal/x.py, which splitInternalFiles treats as internal. It was deployed as a notebook, then its notebook header was dropped. An apply from a fresh checkout leaves {x.py, is_notebook:true} out of the snapshot, so the sync uploads x.py as a plain file and deletes nothing. Here the kept entry's remote name x doesn't collide with x.py, so it is appended. deployment.json now lists x.py twice, and every later plain deploy from a fresh checkout fails in StatePull with expected only one entry per file. Can you also mark each synced LocalPath as taken and skip kept entries whose local path is already listed? The doc comment on lines 83-85 should then mention both checks.

type stateUpdate struct{}
type stateUpdate struct {
// keepInternalFiles keeps listing the previous state's entries under the
// target's .internal directory that are not on disk; see StateUpdateForSavedPlan.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] The comment says entries are kept when they are "not on disk", but withKeptFiles decides by remote name and by what the sync deleted. Whether the file is on disk doesn't matter: a missing converted.py entry is dropped when a synced converted.ipynb has the same remote name. Maybe: "keeps listing the previous state's entries under the target's .internal directory whose remote name no synced file uses and this run's sync did not delete; see StateUpdateForSavedPlan."

denik and others added 8 commits November 30, 2026 10:03
Applying a saved plan from a fresh checkout keeps the remote wrapper
notebooks (the build that writes them is skipped), but the pushed
deployment state dropped them, so no later deploy deleted them.
StatePullForSavedPlan now records the kept entries and StateUpdate
lists them again.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Recording the kept entries during the state pull missed applies where
the pull did not restore the state (cache kept, or a retry after a
failed apply). StateUpdateForSavedPlan now takes the .internal entries
from the previous deployment state it already loads.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
When bundle plan and bundle deploy --plan run in one checkout, the
apply's sync deletes a wrapper no task needs any more. Re-listing it
made every later apply delete it again. Sync now reports the remote
names it deleted, and StateUpdateForSavedPlan skips those.

Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
A kept x.py notebook next to a synced x.ipynb has the same remote name,
and a state listing both cannot be restored into a sync snapshot.
withKeptFiles now skips kept entries whose remote name a synced file
uses or the sync deleted. The unit test covers an internal file that is
synced again and a notebook converted to .ipynb. Sync.Deleted() is
reset at the start of every run.

Co-authored-by: Isaac <no-reply@databricks.com>
errcode was removed on main in #7975.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik force-pushed the denik/readplan-keep-wrapper-in-state branch from 49a5e87 to e350cab Compare November 30, 2026 10:09
@denik
denik requested a review from andrewnester November 30, 2026 10:32

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.

3 participants