Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions acceptance/bundle/python/jobs-support/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bundle:
name: my_project

sync: {paths: []} # don't need to copy files

python:
resources:
- "resources:load_resources"
mutators:
- "mutators:update_job"

resources:
jobs:
my_job_1:
name: "My Job 1"
11 changes: 11 additions & 0 deletions acceptance/bundle/python/jobs-support/mutators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses import replace

from databricks.bundles.core import job_mutator
from databricks.bundles.jobs import Job


@job_mutator
def update_job(job: Job) -> Job:
assert isinstance(job.name, str)

return replace(job, name=f"{job.name} (updated)")
4 changes: 4 additions & 0 deletions acceptance/bundle/python/jobs-support/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions acceptance/bundle/python/jobs-support/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

>>> uv run [UV_ARGS] -q [CLI] bundle validate --output json
{
"experimental": {
"python": {
"mutators": [
"mutators:update_job"
],
"resources": [
"resources:load_resources"
]
}
},
"resources": {
"jobs": {
"my_job_1": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "My Job 1 (updated)",
"queue": {
"enabled": true
}
},
"my_job_2": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "My Job 2 (updated)",
"queue": {
"enabled": true
}
}
}
}
}
9 changes: 9 additions & 0 deletions acceptance/bundle/python/jobs-support/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from databricks.bundles.core import Resources


def load_resources() -> Resources:
resources = Resources()

resources.add_job("my_job_2", {"name": "My Job 2"})

return resources
5 changes: 5 additions & 0 deletions acceptance/bundle/python/jobs-support/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

trace uv run $UV_ARGS -q $CLI bundle validate --output json | \
jq "pick(.experimental.python, .resources)"

rm -fr .databricks __pycache__
18 changes: 4 additions & 14 deletions python/databricks_tests/core/test_python_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,14 @@

_ACCEPTANCE_DIR = Path(__file__).parents[3] / "acceptance" / "bundle" / "python"

# Resources knowingly lacking a <plural>-support fixture. Shrink-only: the test fails
# if an entry here is actually covered, so gaps can only close.
_LACKING = {
# jobs predates the <plural>-support convention; covered across the suite instead.
"jobs",
}

_PLURALS = sorted(t.plural_name for t in _ResourceType.all())


@pytest.mark.parametrize("plural", _PLURALS)
def test_python_support_coverage(plural: str):
covered = (_ACCEPTANCE_DIR / f"{plural}-support" / "databricks.yml").exists()

if plural in _LACKING:
assert not covered, f"{plural!r} now has a fixture; remove it from _LACKING"
else:
assert covered, (
f"no acceptance/bundle/python/{plural}-support/ fixture for {plural!r}; "
"add one (see acceptance/bundle/python/README.md) or add it to _LACKING"
)
assert covered, (
f"no acceptance/bundle/python/{plural}-support/ fixture for {plural!r}; "
"add one (see acceptance/bundle/python/README.md)"
)
Loading