Skip to content

Commit 30c24ff

Browse files
authored
[Breaking Change] Remove deprecated path fallback mechanism for jobs and pipelines (#3225)
## Changes Removed deprecated path fallback mechanism for jobs and pipelines Effectively, it removes an old deprecated behaviour and only relies on the new one introduced here #1273 ## What's changing? Assuming there are the following 2 bundle configuration files in your bundle - `./resources/my_job.yml` - this is where the job is defined - `./override.yml` - this is where the notebook path of the job task is overridden ``` ./resources/my_job.yml resources: jobs: my_job: name: "my job" tasks: - task_key: notebook_example job_cluster_key: default notebook_task: # if not overridden, this resolves to ./resources/original_notebook.py notebook_path: ./original_notebook.py ``` ``` ./override.yml targets: development: resources: jobs: my_job: tasks: - task_key: notebook_example notebook_task: # before this PR: this resolves to <BUNDLE_ROOT>/../src/notebook.py first and if that cannot be done, resolves to <BUNDLE_ROOT>/src/notebook.py # with this PR: this resolves only to <BUNDLE_ROOT>/../src/notebook.py notebook_path: ../src/notebook.py ``` **Before** this change, on `bundle validate / deploy` the notebook_path for notebook_example would resolve to `./src/notebook.py` relative to the bundle root because the relative path was relative to where the job is defined (`/resources/my_job.yml`) **After** this change, the notebook_path for notebook_example would resolve to `../src/notebook.py` relative to the bundle root because now the path is calculated relative to where it's defined (`./override.yml`) ## Action items If you are affected by this change, you can do one of the following: 1. **(recommended)** Make necessary configuration changes to have relative paths defined relative to configuration files they are in, or 2. Pin the CLI version which you use to 0.261.0 or earlier ## Tests Covered by existing acceptance tests
1 parent 3481d4b commit 30c24ff

File tree

10 files changed

+54
-76
lines changed

10 files changed

+54
-76
lines changed

NEXT_CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
## Release v0.266.0
44

55
### Notable Changes
6+
* Breaking change: DABs now return an error when paths are incorrectly defined relative to the job or
7+
pipeline definition location instead of the configuration file location. Previously, the CLI would show a
8+
warning and fallback to resolving the path relative to the resource location. Users must update their bundle
9+
configurations to define all relative paths relative to the configuration file where the path is specified.
10+
See more details here: ([#3225](https://github.com/databricks/cli/pull/3225))
611
* Add support volumes in Python support ([#3383])(https://github.com/databricks/cli/pull/3383))
712

813
### CLI
914

1015
### Dependency updates
1116

1217
### Bundles
18+
* [Breaking Change] Remove deprecated path fallback mechanism for jobs and pipelines ([#3225](https://github.com/databricks/cli/pull/3225))
1319

1420
### API Changes

acceptance/bundle/paths/fallback/output.txt

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,36 @@ Warning: required field "entry_point" is not set
55
in resources/my_job.yml:33:13
66
override_job.yml:29:17
77

8-
Warn: path ../src/notebook.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:9:32). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
9-
Warn: path ../src/file.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:13:30). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
10-
Warn: path ../src/dbt_project is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:17:36). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
11-
Warn: path ../src/sql.sql is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:24:25). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
12-
Warn: path ../dist/wheel2.whl is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:33:24). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
13-
Warn: path ../target/jar2.jar is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:41:24). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
14-
Warn: path ../src/notebook2.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_pipeline.yml:13:23). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
15-
Warn: path ../src/file2.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_pipeline.yml:10:23). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.
8+
Error: path ../src/notebook.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:9:32). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
9+
in override_job.yml:9:32
10+
resources/my_job.yml:9:28
11+
12+
Error: path ../src/file.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:13:30). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
13+
in override_job.yml:13:30
14+
resources/my_job.yml:14:26
15+
16+
Error: path ../src/dbt_project is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:17:36). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
17+
in override_job.yml:17:36
18+
resources/my_job.yml:19:32
19+
20+
Error: path ../src/sql.sql is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:24:25). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
21+
in override_job.yml:24:25
22+
resources/my_job.yml:27:21
23+
24+
Error: path ../dist/wheel2.whl is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:33:24). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
25+
in override_job.yml:33:24
26+
27+
Error: path ../target/jar2.jar is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_job.yml:41:24). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
28+
in override_job.yml:41:24
29+
30+
Error: path ../src/notebook2.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_pipeline.yml:13:23). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
31+
in override_pipeline.yml:13:23
32+
33+
Error: path ../src/file2.py is defined relative to the [TEST_TMP_DIR]/resources directory ([TEST_TMP_DIR]/override_pipeline.yml:10:23). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).
34+
in override_pipeline.yml:10:23
35+
36+
37+
Exit code: 1
1638

1739
>>> [CLI] bundle validate -t error
1840
Warning: required field "entry_point" is not set

acceptance/bundle/paths/fallback_metric/databricks.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

acceptance/bundle/paths/fallback_metric/out.test.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

acceptance/bundle/paths/fallback_metric/resources/job.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

acceptance/bundle/paths/fallback_metric/script

Lines changed: 0 additions & 5 deletions
This file was deleted.

acceptance/bundle/paths/fallback_metric/src/notebook.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/paths/fallback_metric/test.toml

Lines changed: 0 additions & 10 deletions
This file was deleted.

bundle/config/mutator/translate_paths_jobs.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package mutator
22

33
import (
44
"context"
5+
"fmt"
56
"path/filepath"
67
"slices"
78

89
"github.com/databricks/cli/bundle/config/mutator/paths"
910

11+
"github.com/databricks/cli/libs/diag"
1012
"github.com/databricks/cli/libs/dyn"
11-
"github.com/databricks/cli/libs/log"
13+
"github.com/databricks/cli/libs/logdiag"
1214
)
1315

1416
func (t *translateContext) applyJobTranslations(ctx context.Context, v dyn.Value) (dyn.Value, error) {
@@ -45,8 +47,7 @@ func (t *translateContext) applyJobTranslations(ctx context.Context, v dyn.Value
4547
return nv, nil
4648
}
4749

48-
// If we failed to rewrite the path, try to rewrite it relative to the fallback directory.
49-
// We only do this for jobs and pipelines because of the comment in [gatherFallbackPaths].
50+
// If we failed to rewrite the path, it uses an old path format which relied on fallback.
5051
if fallback[key] != "" {
5152
dir, nerr := locationDirectory(v.Location())
5253
if nerr != nil {
@@ -66,8 +67,11 @@ func (t *translateContext) applyJobTranslations(ctx context.Context, v dyn.Value
6667
originalValue := dyn.NewValue(originalPath, v.Locations())
6768
nv, nerr := t.rewriteValue(ctx, p, originalValue, fallback[key], opts)
6869
if nerr == nil {
69-
t.b.Metrics.AddBoolValue("is_job_path_fallback", true)
70-
log.Warnf(ctx, "path %s is defined relative to the %s directory (%s). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.", originalPath, fallback[key], v.Location())
70+
logdiag.LogDiag(ctx, diag.Diagnostic{
71+
Severity: diag.Error,
72+
Summary: fmt.Sprintf("path %s is defined relative to the %s directory (%s). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).", originalPath, fallback[key], v.Location()),
73+
Locations: v.Locations(),
74+
})
7175
return nv, nil
7276
}
7377
}

bundle/config/mutator/translate_paths_pipelines.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package mutator
22

33
import (
44
"context"
5+
"fmt"
56
"path/filepath"
67

78
"github.com/databricks/cli/bundle/config/mutator/paths"
89

10+
"github.com/databricks/cli/libs/diag"
911
"github.com/databricks/cli/libs/dyn"
10-
"github.com/databricks/cli/libs/log"
12+
"github.com/databricks/cli/libs/logdiag"
1113
)
1214

1315
func (t *translateContext) applyPipelineTranslations(ctx context.Context, v dyn.Value) (dyn.Value, error) {
@@ -30,8 +32,7 @@ func (t *translateContext) applyPipelineTranslations(ctx context.Context, v dyn.
3032
return nv, nil
3133
}
3234

33-
// If we failed to rewrite the path, try to rewrite it relative to the fallback directory.
34-
// We only do this for jobs and pipelines because of the comment in [gatherFallbackPaths].
35+
// If we failed to rewrite the path, it uses an old path format which relied on fallback.
3536
if fallback[key] != "" {
3637
dir, nerr := locationDirectory(v.Location())
3738
if nerr != nil {
@@ -51,8 +52,11 @@ func (t *translateContext) applyPipelineTranslations(ctx context.Context, v dyn.
5152
originalValue := dyn.NewValue(originalPath, v.Locations())
5253
nv, nerr := t.rewriteValue(ctx, p, originalValue, fallback[key], opts)
5354
if nerr == nil {
54-
t.b.Metrics.AddBoolValue("is_pipeline_path_fallback", true)
55-
log.Warnf(ctx, "path %s is defined relative to the %s directory (%s). Please update the path to be relative to the file where it is defined. The current value will no longer be valid in the next release.", originalPath, fallback[key], v.Location())
55+
logdiag.LogDiag(ctx, diag.Diagnostic{
56+
Severity: diag.Error,
57+
Summary: fmt.Sprintf("path %s is defined relative to the %s directory (%s). Please update the path to be relative to the file where it is defined or use earlier version of CLI (0.261.0 or earlier).", originalPath, fallback[key], v.Location()),
58+
Locations: v.Locations(),
59+
})
5660
return nv, nil
5761
}
5862
}

0 commit comments

Comments
 (0)