<@ULVA73B9P> Using Prefect 3, I am looking for doc...
# ask-marvin
j
@Marvin Using Prefect 3, I am looking for documentation on the prefect.create_flow_run_from_deployment method. I want to understand what happens to job_variables overriden there. Does it override ALL the job variables? Or merge so that only the ones that are overriden are selected, and keeps the rest?
m
thought for 149.9 seconds
Based on my research, I can now provide a clear answer about how job variables work in Prefect 3.x: When using
create_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:
Copy code
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:
Copy code
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.