Joshua Caskie
07/24/2024, 7:30 PMMarvin
07/24/2024, 7:30 PMjob_variables
section to your deployment definition in the prefect.yaml
file. Here is a guide on how to achieve that:
### Hard-coded Job Variables
To provide environment variables directly in the YAML file:
yaml
deployments:
- name: demo-deployment
entrypoint: demo_project/demo_flow.py:some_work
work_pool:
name: local
job_variables:
env:
EXECUTION_ENVIRONMENT: staging
MY_NOT_SO_SECRET_CONFIG: plumbus
schedule: null
Run the deployment using:
prefect deploy -n demo-deployment
You can then see the job variables in the Configuration tab of the deployment UI.
### Using Existing Environment Variables
If you want to use environment variables that are already set in your local environment, you can template these in the YAML file:
yaml
deployments:
- name: demo-deployment
entrypoint: demo_project/demo_flow.py:some_work
work_pool:
name: local
job_variables:
env:
EXECUTION_ENVIRONMENT: ${EXECUTION_ENVIRONMENT}
MY_NOT_SO_SECRET_CONFIG: ${MY_NOT_SO_SECRET_CONFIG}
schedule: null
Ensure the variables are set in your local environment before running the deployment.
For further details and examples, check out the relevant Prefect guide.
Keep in mind some issues raised in GitHub, like environment variables precedence and module imports, which might affect complex use cases:
- GitHub Issue about precedence and environment variable handling
- GitHub Issue discussing local package imports and PREFECT.yaml usage
You can directly refer to the documentation here for more insights: Prefect Deployment Variables.