From 2bd8223dc998b2bc5fc82335f9bc760c67ffdf1c Mon Sep 17 00:00:00 2001 From: Sankalp-Mittal Date: Mon, 7 Sep 2026 13:06:52 +0000 Subject: [PATCH] Normalize jobs PyDABs acceptance surface and drop coverage exception Add the standard jobs-support/ fixture so jobs matches every other PyDABs resource, then remove the _LACKING exception list from test_python_support_coverage. The guard now uniformly requires a -support/ fixture for every resource. Co-authored-by: Isaac --- .../bundle/python/jobs-support/databricks.yml | 15 +++++++ .../bundle/python/jobs-support/mutators.py | 11 +++++ .../bundle/python/jobs-support/out.test.toml | 4 ++ .../bundle/python/jobs-support/output.txt | 44 +++++++++++++++++++ .../bundle/python/jobs-support/resources.py | 9 ++++ acceptance/bundle/python/jobs-support/script | 5 +++ .../core/test_python_support.py | 18 ++------ 7 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 acceptance/bundle/python/jobs-support/databricks.yml create mode 100644 acceptance/bundle/python/jobs-support/mutators.py create mode 100644 acceptance/bundle/python/jobs-support/out.test.toml create mode 100644 acceptance/bundle/python/jobs-support/output.txt create mode 100644 acceptance/bundle/python/jobs-support/resources.py create mode 100644 acceptance/bundle/python/jobs-support/script diff --git a/acceptance/bundle/python/jobs-support/databricks.yml b/acceptance/bundle/python/jobs-support/databricks.yml new file mode 100644 index 00000000000..583e671060d --- /dev/null +++ b/acceptance/bundle/python/jobs-support/databricks.yml @@ -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" diff --git a/acceptance/bundle/python/jobs-support/mutators.py b/acceptance/bundle/python/jobs-support/mutators.py new file mode 100644 index 00000000000..9335dd63f19 --- /dev/null +++ b/acceptance/bundle/python/jobs-support/mutators.py @@ -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)") diff --git a/acceptance/bundle/python/jobs-support/out.test.toml b/acceptance/bundle/python/jobs-support/out.test.toml new file mode 100644 index 00000000000..164ce535b87 --- /dev/null +++ b/acceptance/bundle/python/jobs-support/out.test.toml @@ -0,0 +1,4 @@ +Cloud = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] +EnvMatrix.DMS = ["", "true"] +EnvMatrix.PYDAB_VERSION = ["0.266.0", "current"] diff --git a/acceptance/bundle/python/jobs-support/output.txt b/acceptance/bundle/python/jobs-support/output.txt new file mode 100644 index 00000000000..c58d1ce8c28 --- /dev/null +++ b/acceptance/bundle/python/jobs-support/output.txt @@ -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 + } + } + } + } +} diff --git a/acceptance/bundle/python/jobs-support/resources.py b/acceptance/bundle/python/jobs-support/resources.py new file mode 100644 index 00000000000..a6e6ce3f4ec --- /dev/null +++ b/acceptance/bundle/python/jobs-support/resources.py @@ -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 diff --git a/acceptance/bundle/python/jobs-support/script b/acceptance/bundle/python/jobs-support/script new file mode 100644 index 00000000000..e273fb45a53 --- /dev/null +++ b/acceptance/bundle/python/jobs-support/script @@ -0,0 +1,5 @@ + +trace uv run $UV_ARGS -q $CLI bundle validate --output json | \ + jq "pick(.experimental.python, .resources)" + +rm -fr .databricks __pycache__ diff --git a/python/databricks_tests/core/test_python_support.py b/python/databricks_tests/core/test_python_support.py index 41a68d86943..0cbe8fb3b4a 100644 --- a/python/databricks_tests/core/test_python_support.py +++ b/python/databricks_tests/core/test_python_support.py @@ -13,13 +13,6 @@ _ACCEPTANCE_DIR = Path(__file__).parents[3] / "acceptance" / "bundle" / "python" -# Resources knowingly lacking a -support fixture. Shrink-only: the test fails -# if an entry here is actually covered, so gaps can only close. -_LACKING = { - # jobs predates the -support convention; covered across the suite instead. - "jobs", -} - _PLURALS = sorted(t.plural_name for t in _ResourceType.all()) @@ -27,10 +20,7 @@ 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)" + )