Override job variables on a deployment to set environment variables, specify a Docker image, allocate resources, and more.
prefect.yaml
file or using the Python deploy
method.
In both cases, you can add or override job variables to the work pool’s defaults for a given deployment.
You can override both a work pool and a deployment when a flow run is triggered.
This guide explores common patterns for overriding job variables in
both deployment methods.
env
field of any work pool:
demo_flow.py
file like:
prefect.yaml
fileprefect.yaml
file at the
root of your repository:
pull
step,
because one is not explicitly defined on the deployment. For reference, here’s what that would look like at
the top of the prefect.yaml
file:EXECUTION_ENVIRONMENT
and MY_NOT_SO_SECRET_CONFIG
environment variables to this deployment,
you can add a job_variables
section to your deployment definition in the prefect.yaml
file:
prefect deploy -n demo-deployment
to deploy the flow with these job variables.
You should see the job variables in the Configuration
tab of the deployment in the UI:
prefect.yaml
file using the {{ $ENV_VAR_NAME }}
syntax:
prefect deploy
is run would have these environment variables set.prefect deploy -n demo-deployment
to deploy the flow with these job variables,
and you should see them in the UI under the Configuration
tab.
.deploy()
method.deploy()
method to deploy your flow, the process is similar. But instead ofprefect.yaml
defining the job variables, you can pass them as a dictionary to the job_variables
argument
of the .deploy()
method.
Add the following block to your demo_project/daily_flow.py
file from the setup section:
demo_project/daily_flow.py
already exists in the repository at the specified pathConfiguration
tab.
env
example from above, you could do the following:
-jv
or --job-variable
flag.