Repository navigation
[AIR] CNXT-2679: warn in dry-run when command uses a path relative to code_source - #7865
vinchenzo-db wants to merge 8 commits into
Conversation
… code_source `air run --dry-run` now warns when `command` refers to a file by a path relative to `code_source.root_path` (for example `python train.py`). At runtime the working directory is not the extracted code directory, so such a run only fails after waiting for a GPU. The warning suggests `$CODE_SOURCE_PATH/<file>` instead. Runs are submitted unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/air/run: branch ✅ | main (1ea5591) ❌ | latest (v1.27.0) ❌main (1ea5591): latest (v1.27.0): |
There was a problem hiding this comment.
Automated review at 0d006ee. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) and 1 question(s) below.
This PR adds a dry-run warning when command refers to a file by a path relative to code_source.root_path, helping users avoid a "No such file or directory" failure after waiting for a GPU. The implementation is a clean heuristic in scriptpathcheck.go with good unit and acceptance test coverage. One minor gap in the token-level flag-value detection could produce a false-positive warning for the space-separated flag form, and two reviewers independently questioned why the warning is scoped to --dry-run only when the analogous torch check fires unconditionally.
Questions
- The warning fires only during
--dry-run(line 174, inside theif dryRunblock), while the analogousmissingTorchWarning(line 168) fires unconditionally for every run. Both checks are local and credential-free. ShouldrelativeScriptWarningalso fire on actual submissions, so a user who runsair run -f workload.yamlwithout--dry-runstill sees the warning before waiting for a GPU? (non-blocking)
✅ Integration test reportCommit: 1d783c3
Top 24 slowest tests (at least 2 minutes):
|
Scanning stops at a `cd` word, so `cd "$CODE_SOURCE_PATH" && python train.py` no longer warns. Container commands get the same check, since each container receives the same code source. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 89bbf70. Each finding was verified against the code.
No blocking issues found. 5 non-blocking comment(s) below.
This PR adds a local check to air run --dry-run that warns when command names a file relative to code_source.root_path and suggests $CODE_SOURCE_PATH/<file>. The idea is sound, but the check looks at the local working tree rather than at the snapshot that gets uploaded, so it can suggest a path that will also fail. The word-by-word matching also produces false warnings for some cd forms, behaves differently on Windows, and treats --flag=value differently from --flag value. None of these break existing behavior, since the output is only a warning.
The warning now matches command words against the files the snapshot would package (working tree or pinned commit, after include_paths), so it fires only when `$CODE_SOURCE_PATH/<file>` will exist, and runs after snapshot selection succeeds. It also checks `--flag=value` values, skips `NAME=value` assignments, stops at `pushd` and `(cd`, and treats a leading `/` as absolute on every OS. Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at af65bcd. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) below.
This PR makes air run --dry-run warn when command or a container command names a snapshot file by a path relative to code_source.root_path, and suggests $CODE_SOURCE_PATH/<file>. To feed the check, the snapshot count helpers now return file lists. The approach is reasonable. One edge case changed in the pinned-commit path: when ls-tree prints nothing, the dry run now reports 1 file where it used to report 0. The heuristic also warns on a few commands that change directory without cd.
Comments outside the changed lines
- [nice to have]
cmd/air/scriptpathcheck.go:139: Scanning only stops at a barecd/pushd, so commands that set the working directory another way still warn. Examples areenv -C "$CODE_SOURCE_PATH" python train.pyanduv run --directory "$CODE_SOURCE_PATH" python train.py: the$word is skipped,train.pymatches, and the user is told a run that works "may fail". Should scanning also stop after a directory flag whose value references$CODE_SOURCE_PATH(-C,--directory,--chdir,--cwd), or is that not worth it?
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 3acf5b9. Each finding was verified against the code.
No blocking issues found. 1 non-blocking comment(s) below.
This PR adds a dry-run warning when command (or a container's command) refers to a snapshot file by a path relative to code_source.root_path. To support it, the snapshot count helper now returns the file list. The listing refactor and the warning look right for the cases the tests cover. One gap: a quoted --flag="value" keeps its opening quote, so that form never warns.
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at d1d5274. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR adds a dry-run warning when command or a container command refers to a snapshot file by a path relative to code_source.root_path, and changes the snapshot counting helper so it returns the file list. The listing change and its tests look right. The word splitting in the new check gives false warnings on some common shell forms, including the &&cd form that the cd stop is supposed to handle. One unit test case is also mislabeled.
Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 52b1d5a. Each finding was verified against the code.
No blocking issues found. 2 non-blocking comment(s) below.
This PR adds a dry-run warning when command or a container's command names a snapshot file by a path relative to code_source.root_path. It also changes the snapshot counting helper so it returns the list of files. The plumbing through listSnapshotFiles / listFilesAtCommit looks correct. I have two notes on the tokenizer. A # comment ends the scan for the whole multi-line command, so a commented first line hides the warning entirely. The container label also doesn't match how validation names containers.
…ime behavior Co-authored-by: Isaac <no-reply@databricks.com>
|
/review |
There was a problem hiding this comment.
Automated review at 1d783c3. Each finding was verified against the code.
No blocking issues found.
This PR makes air run --dry-run warn when command (or a container's command) names a packaged snapshot file by a path relative to code_source.root_path, and suggests $CODE_SOURCE_PATH/<file>. To support that, the snapshot counting helpers now return the file list. I traced the word scan, the cd/pushd/comment handling, the git and working-tree listing paths, and the tests, and found nothing that should block the merge. The check runs only on dry runs and misses some directory-changing forms, but the description says both are deliberate, and it only ever adds an advisory line.
Changes
databricks air run --dry-runnow prints a warning whencommand(or a container'scommand) refers to a snapshot file by a path relative tocode_source.root_path, for examplepython train.pywhentrain.pyis in the snapshot. The warning suggests$CODE_SOURCE_PATH/<file>and links thecommandsection of the YAML config reference, per cloud, from the sameconfigDocsBasesthatair run -h configuses:The check is local and dry-run only, and runs after the snapshot file selection succeeds. It matches command words against the files the snapshot would actually package (working tree or pinned commit, after
include_paths), so it only suggests a path for a file that is actually packaged. Words that reference$CODE_SOURCE_PATH, absolute paths andNAME=valueassignments are skipped;--flag=valueis checked by its value; scanning stops atcd/pushd. Runs are submitted unchanged. The snapshot counting helper used by the dry run now returns the file list (listSnapshotFiles), and the count is its length.Why
Fixes CNXT-2679: at runtime the workload command runs from the job's working directory, not from the extracted code snapshot, so
python train.pypasses--dry-runand the workspace-sideconfig:validatebut fails with "No such file or directory" only after the run has waited for a GPU (11.6 min wall time for 0 s of user code in the CUJ PE64 runthrough). Catching the relative path locally, before submission, saves that cycle. This mirrors the existing local torch-import warning incmd/air/torchcheck.go.Tests
cmd/air/scriptpathcheck_test.gocover bare,./-prefixed, quoted and nested paths,--flag=valueand--flag value,$CODE_SOURCE_PATHusage, absolute paths, environment assignments, files outsideinclude_pathsor the snapshot,../paths, directories,cd/(cd/pushdforms, and container commands.TestListFilesAtCommit(renamed from the count test) checks the listed paths for the repo root, aroot_pathsubtree andinclude_paths.acceptance/air/run(relative-script.yaml) showing the warning in dry-run output;torch-standard.yamlalready covers the no-warning path for$CODE_SOURCE_PATH. Thenon-git-subdir.yamlfixture uses the$CODE_SOURCE_PATHform so its output stays about what it tests.go test ./cmd/air/ ./acceptance -run 'TestAccept/air/',task lint-qandtask wspass locally.Hard-coded values
~/loop/bin/cli-checkis clean. The warning no longer states how the runtime behaves (an earlier version said the runtime working directory is not the code directory). It now says only what the CLI can see locally (the command names a path relative tocode_source.root_path), suggests$CODE_SOURCE_PATH, and links the public docs, which own the runtime behavior ("Paths in the command refer to remote file paths in the workload container. When code_source is set, $CODE_SOURCE_PATH contains the absolute path to the extracted code."). How the command string is split into words is the CLI's own local parsing.Review notes
--flag; declined at the time because a relative flag value fails the same way at runtime. Round 2 asked for--flag=valueand--flag valueto behave the same, which is now the case: both are checked by their value.$CODE_SOURCE_PATH(env -C,uv run --directory,--chdir,--cwd). Not applied: that adds a tool-specific flag list to maintain for an advisory line, andcd/pushdcover the documented way to change directory. A false warning in those forms costs one line of output.--dry-runto catch this locally, and the change deliberately leaves the submission path untouched.This pull request and its description were written by Isaac.