Skip to content

Commit 6f8e2b0

Browse files
authored
[Python] Move 'python' outside of experimental (#3540)
## Changes Move `python` outside of the `experimental` section. The change is backward-compatible and forward-compatible. If CLI is using a newer or older version of `databricks-bundles,` it will continue to work. It's implemented by copying the content of `python` into `experimental.python`. If we don't offer compatibility, there is a risk that previously deployed resources will be erased because we wouldn't be able to load resources. See also #3539 ## Why Python support for Databricks Asset Bundles is graduating from the experimental status. ## Tests Acceptance tests check that previous `databricks-bundles` versions continue to work.
1 parent 4f36f56 commit 6f8e2b0

File tree

53 files changed

+606
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+606
-122
lines changed

NEXT_CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
## Release v0.275.0
44

55
### Notable Changes
6+
* Python support for Databricks Asset Bundles is now generally available
67

78
### CLI
8-
99
* Remove `inplace` mode for the `--progress-format` flag. ([#3811](https://github.com/databricks/cli/pull/3811))
1010
* Remove `json` mode for the `--progress-format` flag. ([#3812](https://github.com/databricks/cli/pull/3812))
1111

1212
### Dependency updates
1313

1414
### Bundles
15+
* Add `pydabs` template replacing `experimental-jobs-as-code` template ([#3806](https://github.com/databricks/cli/pull/3806))
16+
* You can now use `python` section instead of `experimental/python` ([#3540](https://github.com/databricks/cli/pull/3540))
1517

1618
### API Changes

acceptance/bundle/help/bundle-init/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TEMPLATE_PATH optionally specifies which template to use. It can be one of the f
77
- default-sql: The default SQL template for .sql files that run with Databricks SQL
88
- dbt-sql: The dbt SQL template (databricks.com/blog/delivering-cost-effective-data-real-time-dbt-and-databricks)
99
- mlops-stacks: The Databricks MLOps Stacks template (github.com/databricks/mlops-stacks)
10-
- experimental-jobs-as-code: Jobs as code template (experimental)
10+
- pydabs: A variant of 'default-python' template that defines resources in Python instead of YAML
1111
- a local file system path with a template directory
1212
- a Git repository URL, e.g. https://github.com/my/repository
1313

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
bundle:
2+
name: my_project
3+
4+
sync: {paths: []} # don't need to copy files
5+
6+
# We DO NOT allow specifying both 'python' and 'experimental/python' if they are not equal.
7+
8+
experimental:
9+
python:
10+
resources:
11+
- "resources:load_resources"
12+
13+
python:
14+
resources:
15+
- "resources:load_resources"

acceptance/bundle/python/experimental-compatibility-both-equal/out.test.toml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json --include-locations
3+
{
4+
"experimental": {
5+
"python": {
6+
"resources": [
7+
"resources:load_resources"
8+
]
9+
}
10+
},
11+
"resources": {
12+
"jobs": {
13+
"my_job": {
14+
"deployment": {
15+
"kind": "BUNDLE",
16+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
17+
},
18+
"edit_mode": "UI_LOCKED",
19+
"format": "MULTI_TASK",
20+
"max_concurrent_runs": 1,
21+
"name": "My Job",
22+
"queue": {
23+
"enabled": true
24+
}
25+
}
26+
}
27+
},
28+
"__locations": {
29+
"files": [
30+
"__generated_by_python__.yml",
31+
"databricks.yml",
32+
"resources.py"
33+
],
34+
"locations": {
35+
"bundle": [
36+
[
37+
1,
38+
2,
39+
3
40+
]
41+
],
42+
"experimental": [
43+
[
44+
1,
45+
9,
46+
3
47+
]
48+
],
49+
"python": [
50+
[
51+
1,
52+
14,
53+
3
54+
]
55+
],
56+
"resources": [
57+
[
58+
0,
59+
1,
60+
880
61+
]
62+
],
63+
"resources.jobs": [
64+
[
65+
0,
66+
1,
67+
889
68+
]
69+
],
70+
"resources.jobs.my_job": [
71+
[
72+
2,
73+
6,
74+
1
75+
]
76+
],
77+
"sync": [
78+
[
79+
1,
80+
4,
81+
7
82+
]
83+
]
84+
}
85+
}
86+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from databricks.bundles.core import Resources
2+
3+
4+
def load_resources() -> Resources:
5+
resources = Resources()
6+
resources.add_job(
7+
resource_name="my_job",
8+
job={"name": "My Job"},
9+
)
10+
11+
return resources
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
echo "$DATABRICKS_BUNDLES_WHEEL" > "requirements-latest.txt"
2+
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)"
7+
8+
rm -fr .databricks __pycache__
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
bundle:
2+
name: my_project
3+
4+
sync: {paths: []} # don't need to copy files
5+
6+
# We allow specifying both 'python' and 'experimental/python' if they are equal.
7+
8+
experimental:
9+
python:
10+
resources:
11+
- "resources:load_resources_1"
12+
13+
python:
14+
resources:
15+
- "resources:load_resources_2"

acceptance/bundle/python/experimental-compatibility-both-error/out.test.toml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json --include-locations
3+
Error: failed to apply python mutator: 'experimental/python' and 'python' configuration properties are mutually exclusive, use only 'python'
4+
5+
{
6+
"experimental": {
7+
"python": {
8+
"resources": [
9+
"resources:load_resources_1"
10+
]
11+
}
12+
},
13+
"resources": null,
14+
"__locations": {
15+
"files": null,
16+
"locations": null
17+
}
18+
}
19+
20+
Exit code: 1

0 commit comments

Comments
 (0)