From 004917ba1d32fde5b1cb6ed0907c0dbed8c261f0 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 03:45:44 +0000 Subject: [PATCH 1/8] [AIR] CNXT-2679: warn in dry-run when command uses a path relative to 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/` instead. Runs are submitted unchanged. Co-authored-by: Isaac --- acceptance/air/run/ignored-root.yaml | 2 +- acceptance/air/run/include-outside-root.yaml | 2 +- acceptance/air/run/non-git-subdir.yaml | 2 +- acceptance/air/run/output.txt | 7 +++ acceptance/air/run/relative-script.yaml | 7 +++ acceptance/air/run/script | 3 + acceptance/air/run/script-src/train.py | 1 + cmd/air/run.go | 3 + cmd/air/scriptpathcheck.go | 35 ++++++++++++ cmd/air/scriptpathcheck_test.go | 58 ++++++++++++++++++++ 10 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 acceptance/air/run/relative-script.yaml create mode 100644 acceptance/air/run/script-src/train.py create mode 100644 cmd/air/scriptpathcheck.go create mode 100644 cmd/air/scriptpathcheck_test.go diff --git a/acceptance/air/run/ignored-root.yaml b/acceptance/air/run/ignored-root.yaml index 0b2840a0cfa..1258b285f2d 100644 --- a/acceptance/air/run/ignored-root.yaml +++ b/acceptance/air/run/ignored-root.yaml @@ -1,5 +1,5 @@ experiment_name: smoke-test -command: python main.py +command: python "$CODE_SOURCE_PATH/main.py" compute: accelerator_type: GPU_1xH100 num_accelerators: 1 diff --git a/acceptance/air/run/include-outside-root.yaml b/acceptance/air/run/include-outside-root.yaml index 92d1980685f..478248d7a0c 100644 --- a/acceptance/air/run/include-outside-root.yaml +++ b/acceptance/air/run/include-outside-root.yaml @@ -1,5 +1,5 @@ experiment_name: smoke-test -command: python train.py +command: python "$CODE_SOURCE_PATH/train.py" compute: accelerator_type: GPU_1xH100 num_accelerators: 1 diff --git a/acceptance/air/run/non-git-subdir.yaml b/acceptance/air/run/non-git-subdir.yaml index b6b6c9878c7..d85a9476561 100644 --- a/acceptance/air/run/non-git-subdir.yaml +++ b/acceptance/air/run/non-git-subdir.yaml @@ -1,5 +1,5 @@ experiment_name: smoke-test -command: python main.py +command: python "$CODE_SOURCE_PATH/main.py" compute: accelerator_type: GPU_1xH100 num_accelerators: 1 diff --git a/acceptance/air/run/output.txt b/acceptance/air/run/output.txt index 64cba1975ae..7ad1eda02ca 100644 --- a/acceptance/air/run/output.txt +++ b/acceptance/air/run/output.txt @@ -100,6 +100,13 @@ Dry run: configuration for "smoke-test" is valid; not submitting. Dry run: code_source snapshot would include 1 file(s). Dry run: configuration for "smoke-test" is valid; not submitting. +=== a script path relative to root_path warns to use CODE_SOURCE_PATH + +>>> [CLI] air run -f relative-script.yaml --dry-run +Warning: command refers to "train.py", a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with "No such file or directory". Use "$CODE_SOURCE_PATH/train.py". +Dry run: code_source snapshot would include 1 file(s). +Dry run: configuration for "smoke-test" is valid; not submitting. + === git.remote is rejected >>> [CLI] air run -f git-remote.yaml --dry-run diff --git a/acceptance/air/run/relative-script.yaml b/acceptance/air/run/relative-script.yaml new file mode 100644 index 00000000000..13fbf85cddf --- /dev/null +++ b/acceptance/air/run/relative-script.yaml @@ -0,0 +1,7 @@ +experiment_name: smoke-test +command: python train.py +compute: + accelerator_type: GPU_1xA10 + num_accelerators: 1 +code_source: + root_path: script-src diff --git a/acceptance/air/run/script b/acceptance/air/run/script index 45c5437b857..419052f0bf1 100644 --- a/acceptance/air/run/script +++ b/acceptance/air/run/script @@ -56,6 +56,9 @@ trace $CLI air run -f torch-standard.yaml --dry-run title "the Databricks AI environment provides torch, so no warning" trace $CLI air run -f torch-databricks-ai.yaml --dry-run +title "a script path relative to root_path warns to use CODE_SOURCE_PATH" +trace $CLI air run -f relative-script.yaml --dry-run + title "git.remote is rejected" errcode trace $CLI air run -f git-remote.yaml --dry-run diff --git a/acceptance/air/run/script-src/train.py b/acceptance/air/run/script-src/train.py new file mode 100644 index 00000000000..11b15b1a458 --- /dev/null +++ b/acceptance/air/run/script-src/train.py @@ -0,0 +1 @@ +print("hello") diff --git a/cmd/air/run.go b/cmd/air/run.go index 1baf2ad0e60..22e5a4f97e4 100644 --- a/cmd/air/run.go +++ b/cmd/air/run.go @@ -171,6 +171,9 @@ databricks-ai-runtime skill: if dryRun { // Local and credential-free, so it runs before workspace validation. + if msg := relativeScriptWarning(ctx, cfg, file); msg != "" { + cmdio.LogString(ctx, msg) + } var snapshotFileCount *int if cfg.CodeSource != nil && cfg.CodeSource.Snapshot != nil { count, err := countSnapshotFiles(ctx, cfg.CodeSource.Snapshot, file) diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go new file mode 100644 index 00000000000..9762da3dbf4 --- /dev/null +++ b/cmd/air/scriptpathcheck.go @@ -0,0 +1,35 @@ +package aircmd + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" +) + +// relativeScriptWarning returns a warning when command refers to a file by a +// path relative to code_source.root_path, such as `python train.py`, or "" when +// it doesn't or the check doesn't apply. The runtime working directory is not the +// extracted code directory, so such a run only fails after it waits for a GPU. +func relativeScriptWarning(ctx context.Context, cfg *runConfig, configPath string) string { + if cfg.Command == nil || cfg.CodeSource == nil || cfg.CodeSource.Snapshot == nil { + return "" + } + repoPath, err := resolveRootPath(ctx, cfg.CodeSource.Snapshot.RootPath, filepath.Dir(configPath)) + if err != nil { + return "" + } + for word := range strings.FieldsSeq(*cfg.Command) { + rel := strings.Trim(word, `"'`) + if rel == "" || strings.ContainsAny(rel, "$=") || filepath.IsAbs(rel) { + continue + } + info, err := os.Stat(filepath.Join(repoPath, rel)) + if err != nil || info.IsDir() { + continue + } + return fmt.Sprintf("Warning: command refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", rel, filepath.ToSlash(filepath.Clean(rel))) + } + return "" +} diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go new file mode 100644 index 00000000000..8dafbdbf236 --- /dev/null +++ b/cmd/air/scriptpathcheck_test.go @@ -0,0 +1,58 @@ +package aircmd + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestRelativeScriptWarning(t *testing.T) { + cases := []struct { + name string + command string + word string // the command word reported, "" when no warning is expected + suggest string // the path suggested under $CODE_SOURCE_PATH + }{ + {"bare script", "python train.py", "train.py", "train.py"}, + {"dot-slash script", "./train.py --epochs 1", "./train.py", "train.py"}, + {"quoted nested script", `torchrun --nproc_per_node=8 "src/main.py"`, "src/main.py", "src/main.py"}, + {"code source path variable", `python "$CODE_SOURCE_PATH/train.py"`, "", ""}, + {"flag value", "python -m mod --config=train.py", "", ""}, + {"missing file", "python other.py", "", ""}, + {"directory", "ls src", "", ""}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + require.NoError(t, os.MkdirAll(filepath.Join(dir, "src"), 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "src", "main.py"), []byte("print(1)\n"), 0o644)) + yaml := "experiment_name: e\ncompute:\n num_accelerators: 1\n accelerator_type: GPU_1xA10\ncode_source:\n root_path: .\ncommand: " + tc.command + "\n" + path := filepath.Join(dir, "run.yaml") + require.NoError(t, os.WriteFile(path, []byte(yaml), 0o644)) + cfg, err := loadRunConfig(path) + require.NoError(t, err) + + got := relativeScriptWarning(t.Context(), cfg, path) + if tc.word == "" { + assert.Empty(t, got) + return + } + assert.Contains(t, got, "Warning: command refers to \""+tc.word+"\"") + assert.Contains(t, got, "Use \"$CODE_SOURCE_PATH/"+tc.suggest+"\".") + }) + } +} + +func TestRelativeScriptWarningWithoutCodeSource(t *testing.T) { + dir := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) + path := filepath.Join(dir, "run.yaml") + require.NoError(t, os.WriteFile(path, []byte("experiment_name: e\ncompute:\n num_accelerators: 1\n accelerator_type: GPU_1xA10\ncommand: python train.py\n"), 0o644)) + cfg, err := loadRunConfig(path) + require.NoError(t, err) + assert.Empty(t, relativeScriptWarning(t.Context(), cfg, path)) +} From 0d006ee79d2fb40cae2225dc667669b640a7aaff Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 03:46:16 +0000 Subject: [PATCH 2/8] Add changelog fragment Co-authored-by: Isaac --- .nextchanges/air/dry-run-relative-script-warning.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/air/dry-run-relative-script-warning.md diff --git a/.nextchanges/air/dry-run-relative-script-warning.md b/.nextchanges/air/dry-run-relative-script-warning.md new file mode 100644 index 00000000000..6a5709f2df4 --- /dev/null +++ b/.nextchanges/air/dry-run-relative-script-warning.md @@ -0,0 +1 @@ +* `air run --dry-run` warns when `command` refers to a file by a path relative to `code_source.root_path` and suggests `$CODE_SOURCE_PATH/`, since the runtime working directory is not the code directory. ([#7865](https://github.com/databricks/cli/pull/7865)) From 89bbf7088c4227840282945fc3b8f3c3f539294c Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Mon, 23 Nov 2026 15:06:41 +0000 Subject: [PATCH 3/8] Stop at cd and check container commands 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 --- cmd/air/scriptpathcheck.go | 43 +++++++++++++++++++++++++++------ cmd/air/scriptpathcheck_test.go | 18 ++++++++++++++ 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go index 9762da3dbf4..f9ea9e69b81 100644 --- a/cmd/air/scriptpathcheck.go +++ b/cmd/air/scriptpathcheck.go @@ -8,20 +8,45 @@ import ( "strings" ) -// relativeScriptWarning returns a warning when command refers to a file by a -// path relative to code_source.root_path, such as `python train.py`, or "" when -// it doesn't or the check doesn't apply. The runtime working directory is not the -// extracted code directory, so such a run only fails after it waits for a GPU. +// relativeScriptWarning returns a warning when command (or a container's +// command) refers to a file by a path relative to code_source.root_path, such as +// `python train.py`, or "" when none does or the check doesn't apply. The runtime +// working directory is not the extracted code directory, so such a run only fails +// after it waits for a GPU. func relativeScriptWarning(ctx context.Context, cfg *runConfig, configPath string) string { - if cfg.Command == nil || cfg.CodeSource == nil || cfg.CodeSource.Snapshot == nil { + if cfg.CodeSource == nil || cfg.CodeSource.Snapshot == nil { return "" } repoPath, err := resolveRootPath(ctx, cfg.CodeSource.Snapshot.RootPath, filepath.Dir(configPath)) if err != nil { return "" } - for word := range strings.FieldsSeq(*cfg.Command) { + if cfg.Command != nil { + if rel := relativeScriptInCommand(repoPath, *cfg.Command); rel != "" { + return relativeScriptMessage("command", rel) + } + } + for _, c := range cfg.Containers { + if c.Command == nil { + continue + } + if rel := relativeScriptInCommand(repoPath, *c.Command); rel != "" { + return relativeScriptMessage(fmt.Sprintf("containers[%s].command", c.Name), rel) + } + } + return "" +} + +// relativeScriptInCommand returns the first word of command that names an +// existing file under repoPath, or "". Scanning stops at a `cd`: once the command +// changes directory, as in `cd "$CODE_SOURCE_PATH" && python train.py`, later +// relative paths are resolved against a directory this check can't know. +func relativeScriptInCommand(repoPath, command string) string { + for word := range strings.FieldsSeq(command) { rel := strings.Trim(word, `"'`) + if rel == "cd" { + return "" + } if rel == "" || strings.ContainsAny(rel, "$=") || filepath.IsAbs(rel) { continue } @@ -29,7 +54,11 @@ func relativeScriptWarning(ctx context.Context, cfg *runConfig, configPath strin if err != nil || info.IsDir() { continue } - return fmt.Sprintf("Warning: command refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", rel, filepath.ToSlash(filepath.Clean(rel))) + return rel } return "" } + +func relativeScriptMessage(field, rel string) string { + return fmt.Sprintf("Warning: %s refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", field, rel, filepath.ToSlash(filepath.Clean(rel))) +} diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go index 8dafbdbf236..2f28d8bd635 100644 --- a/cmd/air/scriptpathcheck_test.go +++ b/cmd/air/scriptpathcheck_test.go @@ -21,6 +21,8 @@ func TestRelativeScriptWarning(t *testing.T) { {"quoted nested script", `torchrun --nproc_per_node=8 "src/main.py"`, "src/main.py", "src/main.py"}, {"code source path variable", `python "$CODE_SOURCE_PATH/train.py"`, "", ""}, {"flag value", "python -m mod --config=train.py", "", ""}, + {"cd into code source first", `cd "$CODE_SOURCE_PATH" && python train.py`, "", ""}, + {"cd elsewhere first", "cd src && python main.py", "", ""}, {"missing file", "python other.py", "", ""}, {"directory", "ls src", "", ""}, } @@ -47,6 +49,22 @@ func TestRelativeScriptWarning(t *testing.T) { } } +func TestRelativeScriptWarningContainers(t *testing.T) { + dir := t.TempDir() + require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) + yaml := "experiment_name: e\ncompute:\n num_accelerators: 2\n accelerator_type: GPU_1xA10\ncode_source:\n root_path: .\n" + + "containers:\n - name: head\n command: python \"$CODE_SOURCE_PATH/train.py\"\n ranks: [0]\n unity_catalog_image: main.s.img:v1\n" + + " - name: worker\n command: python train.py\n ranks: [1]\n unity_catalog_image: main.s.img:v1\n" + path := filepath.Join(dir, "run.yaml") + require.NoError(t, os.WriteFile(path, []byte(yaml), 0o644)) + cfg, err := loadRunConfig(path) + require.NoError(t, err) + + got := relativeScriptWarning(t.Context(), cfg, path) + assert.Contains(t, got, "Warning: containers[worker].command refers to \"train.py\"") + assert.Contains(t, got, "Use \"$CODE_SOURCE_PATH/train.py\".") +} + func TestRelativeScriptWarningWithoutCodeSource(t *testing.T) { dir := t.TempDir() require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) From af65bcd2354a23bef606c0e0bccce567c393f704 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Mon, 23 Nov 2026 15:16:24 +0000 Subject: [PATCH 4/8] Check command paths against the snapshot file list 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/` 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 --- acceptance/air/run/ignored-root.yaml | 2 +- acceptance/air/run/include-outside-root.yaml | 2 +- cmd/air/run.go | 9 +-- cmd/air/scriptpathcheck.go | 56 +++++++++---------- cmd/air/scriptpathcheck_test.go | 59 +++++++------------- cmd/air/snapshot_git.go | 10 ++-- cmd/air/snapshot_git_test.go | 12 ++-- cmd/air/snapshot_upload.go | 20 +++++-- 8 files changed, 79 insertions(+), 91 deletions(-) diff --git a/acceptance/air/run/ignored-root.yaml b/acceptance/air/run/ignored-root.yaml index 1258b285f2d..0b2840a0cfa 100644 --- a/acceptance/air/run/ignored-root.yaml +++ b/acceptance/air/run/ignored-root.yaml @@ -1,5 +1,5 @@ experiment_name: smoke-test -command: python "$CODE_SOURCE_PATH/main.py" +command: python main.py compute: accelerator_type: GPU_1xH100 num_accelerators: 1 diff --git a/acceptance/air/run/include-outside-root.yaml b/acceptance/air/run/include-outside-root.yaml index 478248d7a0c..92d1980685f 100644 --- a/acceptance/air/run/include-outside-root.yaml +++ b/acceptance/air/run/include-outside-root.yaml @@ -1,5 +1,5 @@ experiment_name: smoke-test -command: python "$CODE_SOURCE_PATH/train.py" +command: python train.py compute: accelerator_type: GPU_1xH100 num_accelerators: 1 diff --git a/cmd/air/run.go b/cmd/air/run.go index 22e5a4f97e4..08e0ae0a253 100644 --- a/cmd/air/run.go +++ b/cmd/air/run.go @@ -171,16 +171,17 @@ databricks-ai-runtime skill: if dryRun { // Local and credential-free, so it runs before workspace validation. - if msg := relativeScriptWarning(ctx, cfg, file); msg != "" { - cmdio.LogString(ctx, msg) - } var snapshotFileCount *int if cfg.CodeSource != nil && cfg.CodeSource.Snapshot != nil { - count, err := countSnapshotFiles(ctx, cfg.CodeSource.Snapshot, file) + files, err := listSnapshotFiles(ctx, cfg.CodeSource.Snapshot, file) if err != nil { return err } + count := len(files) snapshotFileCount = &count + if msg := relativeScriptWarning(cfg, files); msg != "" { + cmdio.LogString(ctx, msg) + } } idempotencyToken := effectiveIdempotencyToken(idempotencyKey, cfg) ctx, validationErr := validateDryRunInWorkspace(ctx, cmd, args, cfg, idempotencyToken, validationTimeout) diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go index f9ea9e69b81..f3d6a149061 100644 --- a/cmd/air/scriptpathcheck.go +++ b/cmd/air/scriptpathcheck.go @@ -1,28 +1,21 @@ package aircmd import ( - "context" "fmt" - "os" - "path/filepath" + "path" + "slices" "strings" ) // relativeScriptWarning returns a warning when command (or a container's -// command) refers to a file by a path relative to code_source.root_path, such as -// `python train.py`, or "" when none does or the check doesn't apply. The runtime -// working directory is not the extracted code directory, so such a run only fails -// after it waits for a GPU. -func relativeScriptWarning(ctx context.Context, cfg *runConfig, configPath string) string { - if cfg.CodeSource == nil || cfg.CodeSource.Snapshot == nil { - return "" - } - repoPath, err := resolveRootPath(ctx, cfg.CodeSource.Snapshot.RootPath, filepath.Dir(configPath)) - if err != nil { - return "" - } +// command) refers to a snapshot file by a path relative to code_source.root_path, +// such as `python train.py`, or "" when none does. snapshotFiles are the +// snapshot-relative paths that would be packaged. The runtime working directory +// is not the extracted code directory, so such a run only fails after it waits +// for a GPU. +func relativeScriptWarning(cfg *runConfig, snapshotFiles []string) string { if cfg.Command != nil { - if rel := relativeScriptInCommand(repoPath, *cfg.Command); rel != "" { + if rel := relativeScriptInCommand(*cfg.Command, snapshotFiles); rel != "" { return relativeScriptMessage("command", rel) } } @@ -30,35 +23,40 @@ func relativeScriptWarning(ctx context.Context, cfg *runConfig, configPath strin if c.Command == nil { continue } - if rel := relativeScriptInCommand(repoPath, *c.Command); rel != "" { + if rel := relativeScriptInCommand(*c.Command, snapshotFiles); rel != "" { return relativeScriptMessage(fmt.Sprintf("containers[%s].command", c.Name), rel) } } return "" } -// relativeScriptInCommand returns the first word of command that names an -// existing file under repoPath, or "". Scanning stops at a `cd`: once the command -// changes directory, as in `cd "$CODE_SOURCE_PATH" && python train.py`, later -// relative paths are resolved against a directory this check can't know. -func relativeScriptInCommand(repoPath, command string) string { +// relativeScriptInCommand returns the first word of command that names a file in +// snapshotFiles, or "". A `--flag=value` word is checked by its value; a +// `NAME=value` word is an environment assignment and skipped. Scanning stops at a +// `cd` or `pushd`: once the command changes directory, as in +// `cd "$CODE_SOURCE_PATH" && python train.py`, later relative paths are resolved +// against a directory this check can't know. +func relativeScriptInCommand(command string, snapshotFiles []string) string { for word := range strings.FieldsSeq(command) { - rel := strings.Trim(word, `"'`) - if rel == "cd" { + word = strings.Trim(word, `"'();&|`) + if word == "cd" || word == "pushd" { return "" } - if rel == "" || strings.ContainsAny(rel, "$=") || filepath.IsAbs(rel) { + if strings.HasPrefix(word, "-") { + _, word, _ = strings.Cut(word, "=") + } else if strings.Contains(word, "=") { continue } - info, err := os.Stat(filepath.Join(repoPath, rel)) - if err != nil || info.IsDir() { + if word == "" || strings.Contains(word, "$") || strings.HasPrefix(word, "/") { continue } - return rel + if slices.Contains(snapshotFiles, path.Clean(word)) { + return word + } } return "" } func relativeScriptMessage(field, rel string) string { - return fmt.Sprintf("Warning: %s refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", field, rel, filepath.ToSlash(filepath.Clean(rel))) + return fmt.Sprintf("Warning: %s refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", field, rel, path.Clean(rel)) } diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go index 2f28d8bd635..05bea1ccb82 100644 --- a/cmd/air/scriptpathcheck_test.go +++ b/cmd/air/scriptpathcheck_test.go @@ -1,15 +1,13 @@ package aircmd import ( - "os" - "path/filepath" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRelativeScriptWarning(t *testing.T) { + snapshot := []string{"train.py", "src/main.py", "configs/base.yaml"} cases := []struct { name string command string @@ -19,26 +17,23 @@ func TestRelativeScriptWarning(t *testing.T) { {"bare script", "python train.py", "train.py", "train.py"}, {"dot-slash script", "./train.py --epochs 1", "./train.py", "train.py"}, {"quoted nested script", `torchrun --nproc_per_node=8 "src/main.py"`, "src/main.py", "src/main.py"}, + {"flag value with equals", "python -m mod --config=configs/base.yaml", "configs/base.yaml", "configs/base.yaml"}, + {"flag value with space", "python -m mod --config configs/base.yaml", "configs/base.yaml", "configs/base.yaml"}, {"code source path variable", `python "$CODE_SOURCE_PATH/train.py"`, "", ""}, - {"flag value", "python -m mod --config=train.py", "", ""}, - {"cd into code source first", `cd "$CODE_SOURCE_PATH" && python train.py`, "", ""}, - {"cd elsewhere first", "cd src && python main.py", "", ""}, - {"missing file", "python other.py", "", ""}, + {"absolute path", "python /opt/train.py", "", ""}, + {"environment assignment", "SCRIPT=train.py python -m mod", "", ""}, + {"not in snapshot", "python other.py", "", ""}, + {"local file outside include_paths", "python tools/prep.py", "", ""}, + {"parent directory", "python ../tools/prep.py", "", ""}, {"directory", "ls src", "", ""}, + {"cd into code source first", `cd "$CODE_SOURCE_PATH" && python train.py`, "", ""}, + {"subshell cd", `(cd "$CODE_SOURCE_PATH" && python train.py --epochs 1)`, "", ""}, + {"pushd", `pushd "$CODE_SOURCE_PATH"; python train.py`, "", ""}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { - dir := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(dir, "src"), 0o755)) - require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) - require.NoError(t, os.WriteFile(filepath.Join(dir, "src", "main.py"), []byte("print(1)\n"), 0o644)) - yaml := "experiment_name: e\ncompute:\n num_accelerators: 1\n accelerator_type: GPU_1xA10\ncode_source:\n root_path: .\ncommand: " + tc.command + "\n" - path := filepath.Join(dir, "run.yaml") - require.NoError(t, os.WriteFile(path, []byte(yaml), 0o644)) - cfg, err := loadRunConfig(path) - require.NoError(t, err) - - got := relativeScriptWarning(t.Context(), cfg, path) + cfg := &runConfig{Command: &tc.command} + got := relativeScriptWarning(cfg, snapshot) if tc.word == "" { assert.Empty(t, got) return @@ -50,27 +45,13 @@ func TestRelativeScriptWarning(t *testing.T) { } func TestRelativeScriptWarningContainers(t *testing.T) { - dir := t.TempDir() - require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) - yaml := "experiment_name: e\ncompute:\n num_accelerators: 2\n accelerator_type: GPU_1xA10\ncode_source:\n root_path: .\n" + - "containers:\n - name: head\n command: python \"$CODE_SOURCE_PATH/train.py\"\n ranks: [0]\n unity_catalog_image: main.s.img:v1\n" + - " - name: worker\n command: python train.py\n ranks: [1]\n unity_catalog_image: main.s.img:v1\n" - path := filepath.Join(dir, "run.yaml") - require.NoError(t, os.WriteFile(path, []byte(yaml), 0o644)) - cfg, err := loadRunConfig(path) - require.NoError(t, err) - - got := relativeScriptWarning(t.Context(), cfg, path) + head := `python "$CODE_SOURCE_PATH/train.py"` + worker := "python train.py" + cfg := &runConfig{Containers: []containerConfig{ + {Name: "head", Command: &head}, + {Name: "worker", Command: &worker}, + }} + got := relativeScriptWarning(cfg, []string{"train.py"}) assert.Contains(t, got, "Warning: containers[worker].command refers to \"train.py\"") assert.Contains(t, got, "Use \"$CODE_SOURCE_PATH/train.py\".") } - -func TestRelativeScriptWarningWithoutCodeSource(t *testing.T) { - dir := t.TempDir() - require.NoError(t, os.WriteFile(filepath.Join(dir, "train.py"), []byte("print(1)\n"), 0o644)) - path := filepath.Join(dir, "run.yaml") - require.NoError(t, os.WriteFile(path, []byte("experiment_name: e\ncompute:\n num_accelerators: 1\n accelerator_type: GPU_1xA10\ncommand: python train.py\n"), 0o644)) - cfg, err := loadRunConfig(path) - require.NoError(t, err) - assert.Empty(t, relativeScriptWarning(t.Context(), cfg, path)) -} diff --git a/cmd/air/snapshot_git.go b/cmd/air/snapshot_git.go index 53d838ef9c0..b2687e0fca4 100644 --- a/cmd/air/snapshot_git.go +++ b/cmd/air/snapshot_git.go @@ -234,9 +234,9 @@ func (g gitRepo) validateIncludePathsExist(ctx context.Context, commitSHA string return nil } -// countFilesAtCommit returns how many files `git archive` would package from +// listFilesAtCommit returns the files `git archive` would package from // commitSHA, limited to subtreePrefix and includePaths when set. -func (g gitRepo) countFilesAtCommit(ctx context.Context, commitSHA, subtreePrefix string, includePaths []string) (int, error) { +func (g gitRepo) listFilesAtCommit(ctx context.Context, commitSHA, subtreePrefix string, includePaths []string) ([]string, error) { treeish := commitSHA lsTreeGit := g if subtreePrefix != "" { @@ -245,7 +245,7 @@ func (g gitRepo) countFilesAtCommit(ctx context.Context, commitSHA, subtreePrefi // as createGitArchiveSnapshot does. repoRoot, err := g.repositoryRoot(ctx) if err != nil { - return 0, err + return nil, err } lsTreeGit = newGitRepo(repoRoot) treeish = commitSHA + ":" + subtreePrefix @@ -253,9 +253,9 @@ func (g gitRepo) countFilesAtCommit(ctx context.Context, commitSHA, subtreePrefi args := append([]string{"ls-tree", "-r", "-z", "--name-only", treeish, "--"}, includePaths...) out, err := lsTreeGit.runBytes(ctx, args...) if err != nil { - return 0, err + return nil, err } - return bytes.Count(out, []byte{0}), nil + return strings.Split(strings.TrimSuffix(string(out), "\x00"), "\x00"), nil } // shortSHA abbreviates a commit SHA to 8 chars for log/error messages, tolerating diff --git a/cmd/air/snapshot_git_test.go b/cmd/air/snapshot_git_test.go index 0c721ec7eb5..6a36ed62e60 100644 --- a/cmd/air/snapshot_git_test.go +++ b/cmd/air/snapshot_git_test.go @@ -370,9 +370,9 @@ func TestCountFilesAtCommit(t *testing.T) { writeRepoFile(t, repo, "subpkg/nested/util.py", "pass") sha := commitAll(t, repo, "init") - count, err := newGitRepo(repo).countFilesAtCommit(ctx, sha, "", nil) + files, err := newGitRepo(repo).listFilesAtCommit(ctx, sha, "", nil) require.NoError(t, err) - assert.Equal(t, 3, count) + assert.Equal(t, []string{"README.md", "subpkg/nested/util.py", "subpkg/train.py"}, files) // root_path below the repo root: git runs from the subfolder, and the count // must still cover the whole subtree, as `git archive` does. @@ -380,11 +380,11 @@ func TestCountFilesAtCommit(t *testing.T) { prefix, err := subGit.repoRelativePrefix(ctx) require.NoError(t, err) - count, err = subGit.countFilesAtCommit(ctx, sha, prefix, nil) + files, err = subGit.listFilesAtCommit(ctx, sha, prefix, nil) require.NoError(t, err) - assert.Equal(t, 2, count) + assert.Equal(t, []string{"nested/util.py", "train.py"}, files) - count, err = subGit.countFilesAtCommit(ctx, sha, prefix, []string{"nested"}) + files, err = subGit.listFilesAtCommit(ctx, sha, prefix, []string{"nested"}) require.NoError(t, err) - assert.Equal(t, 1, count) + assert.Equal(t, []string{"nested/util.py"}, files) } diff --git a/cmd/air/snapshot_upload.go b/cmd/air/snapshot_upload.go index 209139c4055..6e69f1fbf05 100644 --- a/cmd/air/snapshot_upload.go +++ b/cmd/air/snapshot_upload.go @@ -117,23 +117,31 @@ func uploadSnapshotSidecars(ctx context.Context, sidecarStore filer.Filer, sidec return path.Join(sidecarBase, gitStateName), diffPath } -// countSnapshotFiles runs the snapshot file selection without packaging or +// listSnapshotFiles runs the snapshot file selection without packaging or // uploading, so --dry-run fails on the same selection errors as a submission. -func countSnapshotFiles(ctx context.Context, snap *snapshotSourceConfig, configPath string) (int, error) { +// It returns the snapshot-relative, slash-separated paths that would be packaged. +func listSnapshotFiles(ctx context.Context, snap *snapshotSourceConfig, configPath string) ([]string, error) { repoPath, err := resolveRootPath(ctx, snap.RootPath, filepath.Dir(configPath)) if err != nil { - return 0, err + return nil, err } git := newGitRepo(repoPath) plan, err := resolveSnapshotPlan(ctx, git, snap.Git, snap.IncludePaths) if err != nil { - return 0, err + return nil, err } if plan.mode == modeGitArchive { - return git.countFilesAtCommit(ctx, plan.commitSHA, plan.subtreePrefix, plan.includePaths) + return git.listFilesAtCommit(ctx, plan.commitSHA, plan.subtreePrefix, plan.includePaths) } files, err := snapshotFiles(ctx, repoPath, plan.includePaths, plan.isGitRepo) - return len(files), err + if err != nil { + return nil, err + } + rels := make([]string, len(files)) + for i, f := range files { + rels[i] = filepath.ToSlash(f.rel) + } + return rels, nil } // snapshotTarName resolves the content-addressed upload filename for the snapshot and, From 3acf5b93014b4e00a4a18971bf7db6e7f06b0e97 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Mon, 23 Nov 2026 15:24:26 +0000 Subject: [PATCH 5/8] List no files for an empty ls-tree and rename the test Co-authored-by: Isaac --- cmd/air/snapshot_git.go | 2 +- cmd/air/snapshot_git_test.go | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/air/snapshot_git.go b/cmd/air/snapshot_git.go index b2687e0fca4..14792019b7c 100644 --- a/cmd/air/snapshot_git.go +++ b/cmd/air/snapshot_git.go @@ -255,7 +255,7 @@ func (g gitRepo) listFilesAtCommit(ctx context.Context, commitSHA, subtreePrefix if err != nil { return nil, err } - return strings.Split(strings.TrimSuffix(string(out), "\x00"), "\x00"), nil + return strings.FieldsFunc(string(out), func(r rune) bool { return r == 0 }), nil } // shortSHA abbreviates a commit SHA to 8 chars for log/error messages, tolerating diff --git a/cmd/air/snapshot_git_test.go b/cmd/air/snapshot_git_test.go index 6a36ed62e60..764f9272b22 100644 --- a/cmd/air/snapshot_git_test.go +++ b/cmd/air/snapshot_git_test.go @@ -362,7 +362,7 @@ func TestCaptureDirtyDiff_IncludePaths(t *testing.T) { var fixedNow = time.Date(2026, 7, 10, 12, 0, 0, 0, time.UTC) -func TestCountFilesAtCommit(t *testing.T) { +func TestListFilesAtCommit(t *testing.T) { ctx := t.Context() repo := newTestRepo(t) writeRepoFile(t, repo, "README.md", "repo root") @@ -374,7 +374,7 @@ func TestCountFilesAtCommit(t *testing.T) { require.NoError(t, err) assert.Equal(t, []string{"README.md", "subpkg/nested/util.py", "subpkg/train.py"}, files) - // root_path below the repo root: git runs from the subfolder, and the count + // root_path below the repo root: git runs from the subfolder, and the listing // must still cover the whole subtree, as `git archive` does. subGit := newGitRepo(filepath.Join(repo, "subpkg")) prefix, err := subGit.repoRelativePrefix(ctx) @@ -387,4 +387,9 @@ func TestCountFilesAtCommit(t *testing.T) { files, err = subGit.listFilesAtCommit(ctx, sha, prefix, []string{"nested"}) require.NoError(t, err) assert.Equal(t, []string{"nested/util.py"}, files) + + // A selection that matches nothing lists no files rather than one empty name. + files, err = subGit.listFilesAtCommit(ctx, sha, prefix, []string{"missing"}) + require.NoError(t, err) + assert.Empty(t, files) } From d1d52743793c6d7d143aaab6f1bb2f18ca2626b3 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Mon, 23 Nov 2026 15:31:09 +0000 Subject: [PATCH 6/8] Trim quotes from a --flag=value value Co-authored-by: Isaac --- cmd/air/scriptpathcheck.go | 1 + cmd/air/scriptpathcheck_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go index f3d6a149061..314957c7dda 100644 --- a/cmd/air/scriptpathcheck.go +++ b/cmd/air/scriptpathcheck.go @@ -44,6 +44,7 @@ func relativeScriptInCommand(command string, snapshotFiles []string) string { } if strings.HasPrefix(word, "-") { _, word, _ = strings.Cut(word, "=") + word = strings.Trim(word, `"'`) } else if strings.Contains(word, "=") { continue } diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go index 05bea1ccb82..b15050426ab 100644 --- a/cmd/air/scriptpathcheck_test.go +++ b/cmd/air/scriptpathcheck_test.go @@ -19,6 +19,7 @@ func TestRelativeScriptWarning(t *testing.T) { {"quoted nested script", `torchrun --nproc_per_node=8 "src/main.py"`, "src/main.py", "src/main.py"}, {"flag value with equals", "python -m mod --config=configs/base.yaml", "configs/base.yaml", "configs/base.yaml"}, {"flag value with space", "python -m mod --config configs/base.yaml", "configs/base.yaml", "configs/base.yaml"}, + {"quoted flag value with equals", `python -m mod --config="configs/base.yaml"`, "configs/base.yaml", "configs/base.yaml"}, {"code source path variable", `python "$CODE_SOURCE_PATH/train.py"`, "", ""}, {"absolute path", "python /opt/train.py", "", ""}, {"environment assignment", "SCRIPT=train.py python -m mod", "", ""}, From 52b1d5a78f466caae41453fae393e015835fb165 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Mon, 23 Nov 2026 15:37:50 +0000 Subject: [PATCH 7/8] Split command words on shell operators and stop at comments Co-authored-by: Isaac --- cmd/air/scriptpathcheck.go | 16 +++++++++++----- cmd/air/scriptpathcheck_test.go | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go index 314957c7dda..72d4b582b39 100644 --- a/cmd/air/scriptpathcheck.go +++ b/cmd/air/scriptpathcheck.go @@ -5,6 +5,7 @@ import ( "path" "slices" "strings" + "unicode" ) // relativeScriptWarning returns a warning when command (or a container's @@ -31,15 +32,16 @@ func relativeScriptWarning(cfg *runConfig, snapshotFiles []string) string { } // relativeScriptInCommand returns the first word of command that names a file in -// snapshotFiles, or "". A `--flag=value` word is checked by its value; a +// snapshotFiles, or "". Words are split on whitespace and shell operators, so +// `&&cd` is seen as `cd`. A `--flag=value` word is checked by its value; a // `NAME=value` word is an environment assignment and skipped. Scanning stops at a -// `cd` or `pushd`: once the command changes directory, as in +// `#` comment and at a `cd` or `pushd`: once the command changes directory, as in // `cd "$CODE_SOURCE_PATH" && python train.py`, later relative paths are resolved // against a directory this check can't know. func relativeScriptInCommand(command string, snapshotFiles []string) string { - for word := range strings.FieldsSeq(command) { - word = strings.Trim(word, `"'();&|`) - if word == "cd" || word == "pushd" { + for word := range strings.FieldsFuncSeq(command, isShellWordBreak) { + word = strings.Trim(word, `"'`) + if word == "cd" || word == "pushd" || strings.HasPrefix(word, "#") { return "" } if strings.HasPrefix(word, "-") { @@ -58,6 +60,10 @@ func relativeScriptInCommand(command string, snapshotFiles []string) string { return "" } +func isShellWordBreak(r rune) bool { + return unicode.IsSpace(r) || strings.ContainsRune(";&|()", r) +} + func relativeScriptMessage(field, rel string) string { return fmt.Sprintf("Warning: %s refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", field, rel, path.Clean(rel)) } diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go index b15050426ab..a47feb175d1 100644 --- a/cmd/air/scriptpathcheck_test.go +++ b/cmd/air/scriptpathcheck_test.go @@ -24,12 +24,14 @@ func TestRelativeScriptWarning(t *testing.T) { {"absolute path", "python /opt/train.py", "", ""}, {"environment assignment", "SCRIPT=train.py python -m mod", "", ""}, {"not in snapshot", "python other.py", "", ""}, - {"local file outside include_paths", "python tools/prep.py", "", ""}, {"parent directory", "python ../tools/prep.py", "", ""}, {"directory", "ls src", "", ""}, {"cd into code source first", `cd "$CODE_SOURCE_PATH" && python train.py`, "", ""}, {"subshell cd", `(cd "$CODE_SOURCE_PATH" && python train.py --epochs 1)`, "", ""}, {"pushd", `pushd "$CODE_SOURCE_PATH"; python train.py`, "", ""}, + {"glued cd", `pip install -r "$CODE_SOURCE_PATH/req.txt"&&cd "$CODE_SOURCE_PATH" && python train.py`, "", ""}, + {"comment", `python "$CODE_SOURCE_PATH/train.py" # was train.py`, "", ""}, + {"path before a comment", "python train.py # entrypoint", "train.py", "train.py"}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { From 1d783c39e8cd760db40d35078f182014bf2c60de Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 21:47:26 +0000 Subject: [PATCH 8/8] Point the relative script warning at the docs instead of stating runtime behavior Co-authored-by: Isaac --- .../air/dry-run-relative-script-warning.md | 2 +- acceptance/air/run/output.txt | 4 +++- cmd/air/scriptpathcheck.go | 17 +++++++++++++---- cmd/air/scriptpathcheck_test.go | 6 ++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.nextchanges/air/dry-run-relative-script-warning.md b/.nextchanges/air/dry-run-relative-script-warning.md index 6a5709f2df4..07c6e8673c0 100644 --- a/.nextchanges/air/dry-run-relative-script-warning.md +++ b/.nextchanges/air/dry-run-relative-script-warning.md @@ -1 +1 @@ -* `air run --dry-run` warns when `command` refers to a file by a path relative to `code_source.root_path` and suggests `$CODE_SOURCE_PATH/`, since the runtime working directory is not the code directory. ([#7865](https://github.com/databricks/cli/pull/7865)) +* `air run --dry-run` warns when `command` refers to a file by a path relative to `code_source.root_path`, suggests `$CODE_SOURCE_PATH/` and links the docs for command paths. ([#7865](https://github.com/databricks/cli/pull/7865)) diff --git a/acceptance/air/run/output.txt b/acceptance/air/run/output.txt index 7ad1eda02ca..78b1a3cbf2c 100644 --- a/acceptance/air/run/output.txt +++ b/acceptance/air/run/output.txt @@ -103,7 +103,9 @@ Dry run: configuration for "smoke-test" is valid; not submitting. === a script path relative to root_path warns to use CODE_SOURCE_PATH >>> [CLI] air run -f relative-script.yaml --dry-run -Warning: command refers to "train.py", a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with "No such file or directory". Use "$CODE_SOURCE_PATH/train.py". +Warning: command refers to "train.py", a path relative to code_source.root_path. Consider "$CODE_SOURCE_PATH/train.py" instead. See how command paths and $CODE_SOURCE_PATH work: + AWS: https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/yaml-config#command + Azure: https://learn.microsoft.com/azure/databricks/machine-learning/ai-runtime/connecting/cli/yaml-config#command Dry run: code_source snapshot would include 1 file(s). Dry run: configuration for "smoke-test" is valid; not submitting. diff --git a/cmd/air/scriptpathcheck.go b/cmd/air/scriptpathcheck.go index 72d4b582b39..07a37233cc5 100644 --- a/cmd/air/scriptpathcheck.go +++ b/cmd/air/scriptpathcheck.go @@ -11,9 +11,9 @@ import ( // relativeScriptWarning returns a warning when command (or a container's // command) refers to a snapshot file by a path relative to code_source.root_path, // such as `python train.py`, or "" when none does. snapshotFiles are the -// snapshot-relative paths that would be packaged. The runtime working directory -// is not the extracted code directory, so such a run only fails after it waits -// for a GPU. +// snapshot-relative paths that would be packaged. Whether such a path resolves +// depends on the runtime, which the CLI doesn't own, so the warning suggests +// $CODE_SOURCE_PATH and links the docs rather than asserting how the run behaves. func relativeScriptWarning(cfg *runConfig, snapshotFiles []string) string { if cfg.Command != nil { if rel := relativeScriptInCommand(*cfg.Command, snapshotFiles); rel != "" { @@ -65,5 +65,14 @@ func isShellWordBreak(r rune) bool { } func relativeScriptMessage(field, rel string) string { - return fmt.Sprintf("Warning: %s refers to %q, a path relative to code_source.root_path, but at runtime the working directory is not your code directory, so this run may fail with \"No such file or directory\". Use \"$CODE_SOURCE_PATH/%s\".", field, rel, path.Clean(rel)) + var b strings.Builder + fmt.Fprintf(&b, "Warning: %s refers to %q, a path relative to code_source.root_path. Consider \"$CODE_SOURCE_PATH/%s\" instead. See how command paths and $CODE_SOURCE_PATH work:", field, rel, path.Clean(rel)) + for _, d := range configDocsBases { + fmt.Fprintf(&b, "\n %-6s %s%s", d.cloud+":", d.base, yamlConfigDocsPath) + } + return b.String() } + +// yamlConfigDocsPath is the docs page that describes command paths and +// $CODE_SOURCE_PATH; see configDocsBases. +const yamlConfigDocsPath = "/machine-learning/ai-runtime/connecting/cli/yaml-config#command" diff --git a/cmd/air/scriptpathcheck_test.go b/cmd/air/scriptpathcheck_test.go index a47feb175d1..a59ff4dd7a2 100644 --- a/cmd/air/scriptpathcheck_test.go +++ b/cmd/air/scriptpathcheck_test.go @@ -42,7 +42,7 @@ func TestRelativeScriptWarning(t *testing.T) { return } assert.Contains(t, got, "Warning: command refers to \""+tc.word+"\"") - assert.Contains(t, got, "Use \"$CODE_SOURCE_PATH/"+tc.suggest+"\".") + assert.Contains(t, got, "Consider \"$CODE_SOURCE_PATH/"+tc.suggest+"\" instead.") }) } } @@ -56,5 +56,7 @@ func TestRelativeScriptWarningContainers(t *testing.T) { }} got := relativeScriptWarning(cfg, []string{"train.py"}) assert.Contains(t, got, "Warning: containers[worker].command refers to \"train.py\"") - assert.Contains(t, got, "Use \"$CODE_SOURCE_PATH/train.py\".") + assert.Contains(t, got, "Consider \"$CODE_SOURCE_PATH/train.py\" instead.") + assert.Contains(t, got, "https://docs.databricks.com/aws/en/machine-learning/ai-runtime/connecting/cli/yaml-config#command") + assert.Contains(t, got, "https://learn.microsoft.com/azure/databricks/machine-learning/ai-runtime/connecting/cli/yaml-config#command") }