From 4d4d6b5bbcf29602eddbb3b5f087ee09ce87f263 Mon Sep 17 00:00:00 2001 From: Gleb Kanterov Date: Thu, 13 Mar 2025 11:52:09 +0100 Subject: [PATCH] [Python] Clarify mutators behaviour --- .../bundles/core/_resource_mutator.py | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/experimental/python/databricks/bundles/core/_resource_mutator.py b/experimental/python/databricks/bundles/core/_resource_mutator.py index b502a49841..2c35d9ca69 100644 --- a/experimental/python/databricks/bundles/core/_resource_mutator.py +++ b/experimental/python/databricks/bundles/core/_resource_mutator.py @@ -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 + def my_job_mutator(bundle: Bundle, job: Job) -> Job: + return replace(job, name="my_job") See :meth:`databricks.bundles.core.job_mutator`. """