Skip to content

[factory:bug-fixer][custom-training] Report all convert-to-dabs output conflicts before writing (CNXT-2665) - #7859

Open
ben-hansen-db wants to merge 6 commits into
mainfrom
ben-hansen/rf-cnxt-2665
Open

ben-hansen-db wants to merge 6 commits into
mainfrom
ben-hansen/rf-cnxt-2665

Conversation

@ben-hansen-db

@ben-hansen-db ben-hansen-db commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Check the bundle roots and planned sidecars before writing. Report ordinary conflicts together and suggest --force only when it can resolve them all. Return the first filesystem lookup failure. A different workload’s bundle is refused during this same check, even with --force.

Why

If an earlier conversion left sidecars behind, converting a different workload could fail after writing its new bundle root. The resulting bundle could then run the old workload’s command.

These examples start with the same two workload files. An initial conversion of a.yaml writes python a.py to generated_artifacts/command.sh. The second workload, b.yaml, specifies python b.py. Both include hyperparameters.

Before

$ rm databricks.yml
$ databricks air convert-to-dabs b.yaml
Error: failed to write training_config.yaml: training_config.yaml already exists in generated_artifacts; pass --force to overwrite or remove it
$ echo $?
1
$ test -e databricks.yml; echo $?
0
$ cat generated_artifacts/command.sh
python a.py

After

$ rm databricks.yml
$ databricks air convert-to-dabs b.yaml
Error: generated_artifacts/training_config.yaml, generated_artifacts/command.sh, generated_artifacts/hyperparameters.yaml already exist in .; pass --force to overwrite or remove them
$ echo $?
1
$ test -e databricks.yml; echo $?
1
$ cat generated_artifacts/command.sh
python a.py

Tests

The collision table checks the exact error and compares the files before and after failure. The CLI acceptance case removes the generated root, retries conversion, and verifies the root stays absent. A separate regression verifies that refusing a different workload leaves a missing sidecar directory absent.

This PR was written with Codex.

@github-actions github-actions Bot added the AIR Databricks AI Runtime CLI label Nov 20, 2026
@ben-hansen-db
ben-hansen-db marked this pull request as ready for review November 20, 2026 23:25
@ben-hansen-db
ben-hansen-db requested review from a team as code owners November 20, 2026 23:25
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Commit: e7c837bf2 | Workflow run

Regression test report

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

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (c639f9d) latest (v1.28.0)
TestAccept/air/convert-to-dabs ✅ ❌ ❌
TestAccept/air/convert-to-dabs: branch ✅ | main (c639f9d) ❌ | latest (v1.28.0) ❌

main (c639f9d):

acceptance_test.go:1402: Diff:
        --- air/convert-to-dabs/output.txt
        +++ /tmp/TestAcceptairconvert-to-dabs3979490523/002/output.txt
        @@ -94,153 +94,13 @@
         === re-converting refuses to clobber the generated bundle
         
         >>> [CLI] air convert-to-dabs train.yaml
        -Error: databricks.yml, generated_artifacts/training_config.yaml, generated_artifacts/command.sh already exist in .; pass --force to overwrite or remove them
        +Error: databricks.yml already exists in .; pass --force to overwrite or remove it
         
         Exit code: 1
         
         === removing only the bundle root leaves sidecar conflicts
         
         >>> [CLI] air convert-to-dabs train.yaml
        -Error: generated_artifacts/training_config.yaml, generated_artifacts/command.sh already exist in .; pass --force to overwrite or remove them
        +Error: failed to write training_config.yaml: training_config.yaml already exists in generated_artifacts; pass --force to overwrite or remove it
         
        -=== --force overwrites it
        -
        ->>> [CLI] air convert-to-dabs train.yaml --force
        -Wrote a Databricks Asset Bundle to .:
        -  databricks.yml
        -  generated_artifacts/training_config.yaml
        -  generated_artifacts/command.sh
        -
        -To deploy and run this workload as a bundle:
        -  1. [CLI] bundle validate
        -  2. [CLI] bundle deploy
        -  3. [CLI] bundle run torchrun-a10-smoke-test --no-wait
        -
        -bundle deploy uploads the code source and launch scripts automatically.
        -To see what it deployed and where: [CLI] bundle summary
        -
        -Unlike `air run` (which submits an ephemeral run), bundle deploy creates a
        -persistent job that is not garbage-collected. When you are done, remove the
        -job and its uploaded files with:
        -  [CLI] bundle destroy
        -
        -Note: the YAML does not set max_retries, so the job uses the `air run` default
        -(max_retries: 3, retry_on_timeout: true). Edit databricks.yml to change it.
        -
        -=== convert a B300 run using the current SDK
        -
        ->>> [CLI] air convert-to-dabs b300.yaml --output-dir generated-b300
        -Wrote a Databricks Asset Bundle to generated-b300:
        -  databricks.yml
        -  generated_artifacts/training_config.yaml
        -  generated_artifacts/command.sh
        -
        -To deploy and run this workload as a bundle:
        -  1. cd generated-b300
        -  2. [CLI] bundle validate
        -  3. [CLI] bundle deploy
        -  4. [CLI] bundle run b300-smoke-test --no-wait
        -
        -bundle deploy uploads the code source and launch scripts automatically.
        -To see what it deployed and where: [CLI] bundle summary
        -
        -Unlike `air run` (which submits an ephemeral run), bundle deploy creates a
        -persistent job that is not garbage-collected. When you are done, remove the
        -job and its uploaded files with:
        -  [CLI] bundle destroy
        -
        -Note: the YAML does not set max_retries, so the job uses the `air run` default
        -(max_retries: 3, retry_on_timeout: true). Edit databricks.yml to change it.
        -
        -=== the B300 bundle preserves its accelerator and AI Runtime version
        -
        ->>> cat generated-b300/databricks.yml
        -bundle:
        -  name: b300-smoke-test
        -sync:
        -  paths:
        -    - generated_artifacts
        -targets:
        -  dev:
        -    mode: development
        -    default: true
        -resources:
        -  jobs:
        -    b300-smoke-test:
        -      name: b300-smoke-test
        -      tasks:
        -        - task_key: b300-smoke-test
        -          environment_key: default
        -          max_retries: 3
        -          retry_on_timeout: true
        -          ai_runtime_task:
        -            experiment: b300-smoke-test
        -            deployments:
        -              - command_path: ./generated_artifacts/command.sh
        -                compute:
        -                  accelerator_type: GPU_8xB300
        -                  accelerator_count: 8
        -      environments:
        -        - environment_key: default
        -          spec:
        -            environment_version: "6"
        -
        -=== the current SDK recognizes B300 so bundle validation is clean
        -
        ->>> [CLI] bundle validate
        -Name: b300-smoke-test
        -Target: dev
        -Workspace:
        -  User: [USERNAME]
        -  Path: /Workspace/Users/[USERNAME]/.bundle/b300-smoke-test/dev
        -
        -Validation OK!
        -
        -=== --force does not replace a different workload's bundle
        -
        ->>> [CLI] air convert-to-dabs databricks-ai.yaml --force
        -Error: databricks.yml in . belongs to bundle "torchrun-a10-smoke-test", not to this workload's bundle "databricks-ai-v5-smoke-test"; pass --output-dir with another directory that contains the code directory
        -
        -=== databricks_ai versions use a base environment
        -
        ->>> [CLI] air convert-to-dabs databricks-ai.yaml --output-dir generated-databricks-ai
        -Wrote a Databricks Asset Bundle to generated-databricks-ai:
        -  databricks.yml
        -  generated_artifacts/training_config.yaml
        -  generated_artifacts/command.sh
        -
        -To deploy and run this workload as a bundle:
        -  1. cd generated-databricks-ai
        -  2. [CLI] bundle validate
        -  3. [CLI] bundle deploy
        -  4. [CLI] bundle run databricks-ai-v5-smoke-test --no-wait
        -
        -bundle deploy uploads the code source and launch scripts automatically.
        -To see what it deployed and where: [CLI] bundle summary
        -
        -Unlike `air run` (which submits an ephemeral run), bundle deploy creates a
        -persistent job that is not garbage-collected. When you are done, remove the
        -job and its uploaded files with:
        -  [CLI] bundle destroy
        -
        -Note: the YAML does not set max_retries, so the job uses the `air run` default
        -(max_retries: 3, retry_on_timeout: true). Edit databricks.yml to change it.
        -
        ->>> grep -E environment_version|base_environment generated-databricks-ai/databricks.yml
        -            base_environment: workspace-base-environments/databricks_ai_v5
        -
        -=== the Databricks AI bundle validates
        -
        ->>> [CLI] bundle validate
        -Name: databricks-ai-v5-smoke-test
        -Target: dev
        -Workspace:
        -  User: [USERNAME]
        -  Path: /Workspace/Users/[USERNAME]/.bundle/databricks-ai-v5-smoke-test/dev
        -
        -Validation OK!
        -
        -=== a parent that already holds a bundle is not suggested: converting there would replace it
        -
        ->>> [CLI] air convert-to-dabs workloads/eval.yaml
        -Error: code_source root_path "../src" ([TEST_TMP_DIR]/src) is not inside the bundle directory "workloads", and convert-to-dabs can package only code inside the bundle directory; [TEST_TMP_DIR] already holds a bundle (databricks.yml), and converting there would replace it; pass --output-dir with another directory that contains the code directory, or move the code inside the bundle directory
        +Exit code: 1
        
    acceptance_test.go:1192: Test produced unexpected files:
        .databricks/.gitignore
FAIL

latest (v1.28.0): same output as main (c639f9d)

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

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

This PR adds a preflight pass (checkBundleOutputPaths) that detects all conflicting output paths before writing any files during air convert-to-dabs, fixing a real bug where a partial bundle could be left behind. The approach is sound, but the test file uses syscall.ELOOP, which is undefined on Windows and will break compilation there. The write paths after the preflight should unconditionally overwrite (as the base code did for SaveAsYAML) to avoid inconsistent error messages in a narrow TOCTOU race.

"path/filepath"
"runtime"
"slices"
"strings"

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] syscall.ELOOP is not defined on Windows. Because the import and usage (line 244) live in a file with no build constraint, the entire test file fails to compile on GOOS=windows. The runtime.GOOS == "windows" / t.Skip guard at line 221 is a runtime check and never runs when the build itself is broken. Move TestConvertToDabsPreflightsSymlinkLookupErrors and the "syscall" import into a _unix_test.go file behind //go:build !windows, or replace syscall.ELOOP with a platform-neutral check (e.g. assert the error string contains the path without asserting the errno).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Go 1.27.4 declares syscall.ELOOP on Windows. I cross-compiled var _ error = syscall.ELOOP for windows/amd64 with the pinned toolchain, so the test can keep its errors.Is assertion. Go 1.27.4 Windows errno definitions

// above already decided whether overwriting is allowed.
if err := yamlsaver.NewSaver().SaveAsYAML(root, bundlePath, true); err != nil {
bundlePath := filepath.Join(dir, bundleFileName)
if err := yamlsaver.NewSaver().SaveAsYAML(root, bundlePath, force); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nice to have] The base code passed true to SaveAsYAML with an explicit comment: "the collision check above already decided whether overwriting is allowed." The new preflight serves the same role, but now the raw force flag is passed. If force=false and a file races in between the preflight and this call, SaveAsYAML (saver.go:42) produces "<path> already exists. Use --force to overwrite" — different wording and format from the unified preflight message. The same pattern applies at line 724: filer.LocalClient.Write without OverwriteIfExists produces a bare "file already exists: <path>" with no --force hint. Passing true here and always including OverwriteIfExists for the filer restores the base code's intent and avoids the inconsistent error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Passing force through lets the YAML saver refuse a root it sees after preflight. The sidecar writer also opens with O_EXCL by default, so a file created in that interval is preserved. Unconditional overwrite would let a conversion without --force silently replace it.

Comment thread cmd/air/convert_to_dabs.go Resolved
@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: e7c837b

Run: 45506035384

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 20 4:57
💚​ aws-windows-latest-4core-16gb 1 274 18 3:41
💚​ azure linux-2core-8gb 1 271 20 4:53
💚​ azure-windows-latest-4core-16gb 1 273 18 3:57
💚​ gcp linux-2core-8gb 1 272 20 5:27
💚​ gcp-windows-latest-4core-16gb 1 274 18 3:50
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 6 slowest tests (at least 2 minutes):
duration env testname
4:32 gcp linux-2core-8gb TestAccept
3:56 azure linux-2core-8gb TestAccept
3:55 azure-windows-latest-4core-16gb TestAccept
3:53 aws linux-2core-8gb TestAccept
3:48 gcp-windows-latest-4core-16gb TestAccept
3:39 aws-windows-latest-4core-16gb TestAccept

@pardis-beikzadeh-db pardis-beikzadeh-db 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.

Requesting changes for the complexity in the preflight, details inline.

Heads-up: #7857 also changes this check. Whichever PR lands second should move #7857's refusal to replace a different workload's bundle into checkBundleOutputPaths, so it still runs before anything is written.

Comment thread cmd/air/convert_to_dabs.go Resolved
Comment thread cmd/air/convert_to_dabs.go Resolved
Comment thread cmd/air/convert_to_dabs.go Resolved
Comment thread cmd/air/convert_to_dabs_test.go Resolved

@pardis-beikzadeh-db pardis-beikzadeh-db 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.

My earlier comments are addressed.

Comment thread cmd/air/convert_to_dabs.go Resolved
Comment thread cmd/air/convert_to_dabs_test.go Resolved

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

AIR Databricks AI Runtime CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants