Florent VanDeMoortele
06/11/2024, 4:44 PMMarvin
06/11/2024, 4:44 PMprefect.yaml
file, but they are evaluated at runtime rather than being true conditional variables like you might find in a programming language. You can reference these variables using the special syntax {{ prefect.variables.variable_name }}
.
### Example Usage:
You can use variables to templatize deployment steps, as shown below:
yaml
pull:
- prefect.deployments.steps.git_clone:
repository: <https://github.com/PrefectHQ/hello-projects.git>
branch: "{{ prefect.variables.deployment_branch }}"
In this example, the deployment_branch
variable will be evaluated at runtime, allowing you to change its value without updating the deployment directly.
For more details, you can refer to the Prefect documentation on variables and Prefect deployment guides.
It seems we don't have related issues in the GitHub repository for more specific conditional uses, which implies there's not much discussion or feature requests on this topic at the moment.
If you have additional questions or need further examples, feel free to ask.Florent VanDeMoortele
06/11/2024, 4:46 PMMarvin
06/11/2024, 4:46 PMprefect.yaml
file. Here's how you can achieve this:
### Using Environment Variables
You can template environment variables in your prefect.yaml
file using the {{ $ENV_VAR_NAME }}
syntax. This allows you to leverage environment variables that are already set in your CI/CD pipeline.
### Example:
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
In this example:
- EXECUTION_ENVIRONMENT
and MY_NOT_SO_SECRET_CONFIG
will be pulled from the environment variables set in your CI/CD pipeline.
- This templating will allow you to modify the values without hard coding them in the prefect.yaml
file.
You can read more about this in the Prefect Documentation on overriding job variables.
If you have additional queries or need further assistance, feel free to ask.