Joshua Caskie
07/18/2025, 2:56 PMMarvin
07/18/2025, 2:56 PMMarvin
07/18/2025, 2:58 PMcreate_flow_run
(or creating flow runs through other means), job variables follow these behaviors:
1. Merging Behavior: Job variables provided when creating a flow run will override any existing values for the same keys that were set in the deployment or work pool, but won't affect other variables that aren't being overridden.
2. Hierarchy of Precedence:
- Job variables specified at flow run creation have the highest precedence
- Followed by deployment-level job variables
- Finally, work pool default job variables
For example, if you have:
python
# Work pool defaults
job_variables = {
"env": "prod",
"memory": "2GB",
"timeout": "3600"
}
# When creating a flow run
client.create_flow_run(
deployment_id=deployment.id,
job_variables={
"memory": "4GB", # This will override only the memory setting
}
)
The resulting job variables would be:
python
{
"env": "prod", # Preserved from work pool defaults
"memory": "4GB", # Overridden by flow run creation
"timeout": "3600" # Preserved from work pool defaults
}
This allows you to:
- Maintain default settings at the work pool level
- Override specific variables when needed for individual flow runs
- Keep other variables intact when you only need to modify certain values
You can find more details about customizing job variables in the Prefect documentation.