Mat Partridge
12/01/2025, 6:25 PMMarvin
12/01/2025, 6:25 PMNate
12/01/2025, 6:27 PMprefect deployNate
12/01/2025, 6:28 PMfoo != bar in the templates like thatMarvin
12/01/2025, 6:29 PMprefect.yaml templating system does not support expressions, so {{ $PREFECT_DEPLOY_ENV != 'dev' }} won’t work. Only simple placeholder substitution is supported.
What you can do instead:
Option 1: Drive it with a boolean environment variable
- Set an env var to a boolean-like value per environment (e.g., true in prod, false in dev).
- Use the env var directly for active (don’t quote it so it’s treated as a boolean).
prefect.yaml:
deployments:
- name: scheduler
entrypoint: scheduler.py:schedule
schedules:
- cron: "0 1 * * *"
slug: "london-schedule"
timezone: "Europe/London"
active: {{ $SCHEDULE_ACTIVE }}
Then in your deploy environment:
- Prod: export SCHEDULE_ACTIVE=true
- Dev: export SCHEDULE_ACTIVE=false
Notes:
- Acceptable values: `true`/`false`, `1`/`0` (strings are fine; they’ll be coerced to booleans).
- Avoid quotes around the template so it’s not turned into a string.
Option 2: Use a Prefect Variable
- Reference a Prefect variable and set it differently per environment/workspace.
prefect.yaml:
deployments:
- name: scheduler
entrypoint: scheduler.py:schedule
schedules:
- cron: "0 1 * * *"
slug: "london-schedule"
timezone: "Europe/London"
active: {{ prefect.variables.schedule_active }}
Set the variable:
prefect variable set --name schedule_active --value true # prod
prefect variable set --name schedule_active --value false # dev
Option 3: Separate deployments per env
- Define two deployments in the same file and set active statically, then deploy the one you need:
deployments:
- name: scheduler-dev
entrypoint: scheduler.py:schedule
schedules:
- cron: "0 1 * * *"
slug: "london-schedule"
timezone: "Europe/London"
active: false
- name: scheduler-prod
entrypoint: scheduler.py:schedule
schedules:
- cron: "0 1 * * *"
slug: "london-schedule"
timezone: "Europe/London"
active: true
Then deploy the one you want:
prefect deploy --name scheduler-prod
If you share how you’re running prefect deploy (local/CI, single or multiple workspaces), I can suggest the cleanest option for your setup.