Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,29 @@
@dataclass(frozen=True)
class ResourceMutator(Generic[_T]):
"""
Mutators defined within a single Python module are applied in the order they are defined.
The relative order of mutators defined in different modules is not guaranteed.
Resource mutators are used to modify resources before they are deployed.
Mutators are applied both to resources defined in YAML and Python.
Mutators are applied in the order they are defined in databricks.yml.
Example:
.. code-block:: yaml
experimental:
python:
mutators:
- "resources:my_job_mutator"
.. code-block:: python
from databricks.bundles.core import Bundle, job_mutator
from databricks.bundles.jobs import Job
@job_mutator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the decorator only wraps the function in a class, could we get rid of it entirely and just look at the function signature to figure out what kind of mutator it is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find the exact PEP where it's written, but asking ChatGPT:

Python’s design treats annotations as metadata rather than as elements that alter code behavior. In other words, they are intended to provide information (such as type hints) for developers, tools, and static analyzers, without affecting runtime semantics.

def my_job_mutator(bundle: Bundle, job: Job) -> Job:
return replace(job, name="my_job")
See :meth:`databricks.bundles.core.job_mutator`.
"""
Expand Down
Loading