Skip to content

Commit 8fe05d9

Browse files
authored
[Python] Clarify mutators behaviour (#2485)
## Changes Clarify the behavior of Python mutators.
1 parent fbf52ce commit 8fe05d9

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

experimental/python/databricks/bundles/core/_resource_mutator.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,29 @@
1414
@dataclass(frozen=True)
1515
class ResourceMutator(Generic[_T]):
1616
"""
17-
Mutators defined within a single Python module are applied in the order they are defined.
18-
The relative order of mutators defined in different modules is not guaranteed.
17+
Resource mutators are used to modify resources before they are deployed.
18+
19+
Mutators are applied both to resources defined in YAML and Python.
20+
Mutators are applied in the order they are defined in databricks.yml.
21+
22+
Example:
23+
24+
.. code-block:: yaml
25+
26+
experimental:
27+
python:
28+
mutators:
29+
- "resources:my_job_mutator"
30+
31+
.. code-block:: python
32+
33+
from databricks.bundles.core import Bundle, job_mutator
34+
from databricks.bundles.jobs import Job
35+
36+
37+
@job_mutator
38+
def my_job_mutator(bundle: Bundle, job: Job) -> Job:
39+
return replace(job, name="my_job")
1940
2041
See :meth:`databricks.bundles.core.job_mutator`.
2142
"""

0 commit comments

Comments
 (0)