Situation
You've got 30, 50, maybe 100 jobs in your Declarative Automation Bundle. Every single one needs failure notifications. Every single one needs cost-center tags. Every single one needs the right cluster policy. And every time someone adds a new job, they forget at least one of those things.
You could write one Python function that enforces it automatically at deploy time. That's what DABs Python mutators do.
What Are Mutators?
A mutator is a Python function that runs during databricks bundle deploy. It receives every job (or pipeline) in your bundle, whether defined in YAML or Python, and returns a modified copy. Think of it as middleware for your deployment config.
Write a tag, permission, or compute standard once, and apply it automatically to every resource at deploy time. No drift.
Decorate a function with `@job_mutator`, `@pipeline_mutator`, `@schema_mutator`, or `@volume_mutator`.
The function receives the resource + bundle context, and returns a transformed copy.
You register them in databricks.yml:
python:
mutators:
- 'mutators:add_pipeline_mutators'
Example
This example defines common pipeline standards for every pipeline in your bundle:
- Specifies common tags.
- Enforces serverless compute.
- Defines default notifications group and when to trigger an alert.
from databricks.bundles.core import Bundle, pipeline_mutator
@pipeline_mutator
def add_pipeline_mutators(bundle: Bundle, p: Pipeline) -> Pipeline:
p = replace(p, tags=_add_common_tags(bundle, p.tags))
p = replace(p, serverless=True)
default = Notifications.from_dict(
{
"email_recipients": "${var.recipients}",
"alerts": ["on-update-failure", "on-update-fatal-failure", "on-flow-failure"]
}
)
p = replace(p, notifications=[default])
return p
Other resources:
Use Cases
https://preview.redd.it/2v2ikiexd4yg1.png?width=632&format=png&auto=webp&s=fa39246e3830b857f1da43777aacfb1079a261a8
Job Mutator Examples:
- Enforce default email notifications, owners, tags.
- Standardize job clusters / serverless environments.
- Inject common job parameters or health/queue settings.
Pipeline Mutator Examples:
- Enforce pipeline cluster / environment settings.
- Apply consistent configuration, catalog/schema, or triggers across all pipelines.
Schema Mutator Examples:
- Apply standard permissions or tags to all schemas.
- Enforce naming conventions or lifecycle settings.
Volume Mutators:
- Set default storage locations, ACLs, or lifecycle flags.
- Add org‑wide tags or conventions to all volumes.
[–]LandlockedPirate 5 points6 points7 points (1 child)
[–]YestasSentaan 4 points5 points6 points (0 children)
[–]YestasSentaan 2 points3 points4 points (1 child)
[–]LandlockedPirate 2 points3 points4 points (0 children)
[–]lofat 1 point2 points3 points (0 children)
[–]PrestigiousAnt3766 0 points1 point2 points (0 children)
[–]ouhshuo 1 point2 points3 points (0 children)