Skip to content

Commit 478a545

Browse files
authored
[Python] Add acceptance tests for locations (#2569)
## Changes Add acceptance tests capturing how locations are recorded. Note that `--include-locations` doesn't include any location "deeper" than "tasks," so we can't use it to test locations for properties with "special" behavior like "notebook_path" that wouldn't have the same location as other properties. For "notebook_path", we keep the location of a virtual file in a bundle root.
1 parent a05088b commit 478a545

File tree

4 files changed

+145
-6
lines changed

4 files changed

+145
-6
lines changed

acceptance/bundle/python/mutator-ordering/output.txt

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json
2+
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json --include-locations
33
{
44
"experimental": {
55
"python": {
@@ -33,5 +33,76 @@
3333
]
3434
}
3535
}
36+
},
37+
"__locations": {
38+
"files": [
39+
"databricks.yml",
40+
"mutators.py"
41+
],
42+
"locations": {
43+
"bundle": [
44+
[
45+
0,
46+
2,
47+
3
48+
]
49+
],
50+
"experimental": [
51+
[
52+
0,
53+
7,
54+
3
55+
]
56+
],
57+
"resources": [
58+
[
59+
0,
60+
13,
61+
3
62+
]
63+
],
64+
"resources.jobs": [
65+
[
66+
0,
67+
14,
68+
5
69+
]
70+
],
71+
"resources.jobs.my_job": [
72+
[
73+
0,
74+
15,
75+
7
76+
]
77+
],
78+
"resources.jobs.my_job.tasks": [
79+
[
80+
0,
81+
15,
82+
14
83+
]
84+
],
85+
"resources.jobs.my_job.tasks[0]": [
86+
[
87+
1,
88+
8,
89+
1
90+
]
91+
],
92+
"resources.jobs.my_job.tasks[1]": [
93+
[
94+
1,
95+
8,
96+
1
97+
]
98+
],
99+
"sync": [
100+
[
101+
0,
102+
4,
103+
7
104+
]
105+
]
106+
}
36107
}
37108
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
UV_ARGS="${UV_ARGS//\[\DATABRICKS_BUNDLES_WHEEL\]/$DATABRICKS_BUNDLES_WHEEL}"
22

3-
trace uv run $UV_ARGS -q $CLI bundle validate --output json | \
4-
jq "pick(.experimental.python, .resources)"
3+
# after mutators are applied, we expect to record location of the last mutator that had any effect
4+
5+
trace uv run $UV_ARGS -q $CLI bundle validate --output json --include-locations | \
6+
jq "pick(.experimental.python, .resources, .__locations.files, .__locations.locations)"
57

68
rm -fr .databricks __pycache__

acceptance/bundle/python/resource-loading/output.txt

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json
2+
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json --include-locations
33
{
44
"experimental": {
55
"python": {
@@ -54,5 +54,69 @@
5454
"tags": {}
5555
}
5656
}
57+
},
58+
"__locations": {
59+
"files": [
60+
"databricks.yml",
61+
"resources.py"
62+
],
63+
"locations": {
64+
"bundle": [
65+
[
66+
0,
67+
2,
68+
3
69+
]
70+
],
71+
"experimental": [
72+
[
73+
0,
74+
7,
75+
3
76+
]
77+
],
78+
"resources": [
79+
[
80+
0,
81+
13,
82+
3
83+
]
84+
],
85+
"resources.jobs": [
86+
[
87+
0,
88+
14,
89+
5
90+
]
91+
],
92+
"resources.jobs.my_job_1": [
93+
[
94+
1,
95+
16,
96+
1
97+
]
98+
],
99+
"resources.jobs.my_job_2": [
100+
[
101+
1,
102+
6,
103+
1
104+
]
105+
],
106+
"resources.jobs.my_job_3": [
107+
[
108+
0,
109+
15,
110+
7
111+
]
112+
],
113+
"sync": [
114+
[
115+
0,
116+
4,
117+
7
118+
]
119+
]
120+
}
57121
}
58122
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
UV_ARGS="${UV_ARGS//\[\DATABRICKS_BUNDLES_WHEEL\]/$DATABRICKS_BUNDLES_WHEEL}"
22

3-
trace uv run $UV_ARGS -q $CLI bundle validate --output json | \
4-
jq "pick(.experimental.python, .resources)"
3+
# each job should record location where add_job function was called
4+
5+
trace uv run $UV_ARGS -q $CLI bundle validate --output json --include-locations | \
6+
jq "pick(.experimental.python, .resources, .__locations.files, .__locations.locations)"
57

68
rm -fr .databricks __pycache__

0 commit comments

Comments
 (0)