<@ULVA73B9P> if I am creating prefect deployments ...
# ask-marvin
r
@Marvin if I am creating prefect deployments using yaml file, is there a way to define multiple schedules for a single deployment, each with their own parameter overrides? I see that this is possible in the web GUI, but how would the yaml be formatted to accomplish this?
m
thought for 292.4 seconds
Short answer: Yes. In Prefect 3.x a single deployment in YAML can have multiple schedules, and each schedule can specify its own parameter overrides. Use the
schedules:
list on the deployment. Each item can be a cron, interval, or rrule schedule and may include
parameters
that are only applied to runs created by that schedule. Those are merged with and override the deployment’s base
parameters
. Example
prefect.yaml
snippet:
Copy code
name: my-project
prefect-version: ">=3.0.0"

deployments:
  - name: my-deployment
    entrypoint: flows/my_flow.py:my_flow
    work_pool_name: my-pool

    # Base parameters for the deployment (used unless overridden by a schedule)
    parameters:
      env: "prod"
      backfill: false

    # Multiple schedules with their own parameter overrides
    schedules:
      # A cron schedule
      - cron: "0 6 * * 1-5"         # Weekdays at 06:00 UTC
        timezone: "UTC"
        slug: "weekday-6am"
        active: true
        parameters:
          backfill: false
          env: "prod"

      # An interval schedule (seconds)
      - interval: 3600               # Every hour
        timezone: "UTC"
        slug: "hourly"
        active: true
        parameters:
          env: "staging"             # Overrides base for this schedule’s runs

      # An RRULE schedule
      - rrule: "FREQ=MONTHLY;BYMONTHDAY=1;BYHOUR=2;BYMINUTE=0"
        timezone: "America/New_York"
        slug: "monthly-first-2am-et"
        active: true
        parameters:
          backfill: true
Notes: -
parameters
under a schedule only affect runs triggered by that schedule and override the deployment’s base
parameters
for those runs. - Valid schedule keys are: - Cron:
cron
,
timezone
,
day_or
(optional),
active
,
parameters
,
slug
- Interval:
interval
(seconds as int/float),
anchor_date
(optional ISO datetime),
timezone
,
active
,
parameters
,
slug
- RRule:
rrule
,
timezone
,
active
,
parameters
,
slug
Run
prefect deploy
from the project directory to register the deployment and all of its schedules. If you’re on Prefect 2.x, the YAML shape differs (and only a single schedule key was supported); the above format is for Prefect 3.x.
r
@Marvin your example shows multiple schedules of different types, but multiple cron schedules would work similarly I'm assuming?
m
thought for 17.1 seconds
Yes—multiple cron schedules work exactly the same way. Just add multiple items to the
schedules:
list, each with its own
cron
,
timezone
, and optional
parameters
,
slug
, etc. Example with only cron schedules:
Copy code
deployments:
  - name: my-deployment
    entrypoint: flows/my_flow.py:my_flow
    work_pool_name: my-pool

    parameters:
      env: "prod"
      backfill: false

    schedules:
      - cron: "0 6 * * 1-5"       # Weekdays at 06:00 UTC
        timezone: "UTC"
        slug: "weekday-6am"
        active: true
        parameters:
          backfill: false

      - cron: "30 18 * * *"       # Every day at 18:30 America/New_York
        timezone: "America/New_York"
        slug: "daily-630pm-et"
        parameters:
          backfill: true

      - cron: "0 0 1 * *"         # First day of month at 00:00 UTC
        timezone: "UTC"
        slug: "monthly-midnight"
        active: false             # you can disable a specific schedule
Notes: - Each cron entry is independent; if two schedules overlap, they will both create runs. - Parameters under a schedule override the deployment’s base
parameters
for runs from that schedule. - Optional keys you can use with cron:
timezone
,
day_or
,
active
,
parameters
,
slug
.
r
@Marvin and if one schedule has its own parameters, but the other does not, then the other will just use the base parameters without any overrides, right?
m
thought for 12.6 seconds
Exactly. If a schedule entry does not specify
parameters
, that schedule will use the deployment’s base
parameters
as-is. Only schedules that include their own
parameters
will override keys they specify. Quick example:
Copy code
deployments:
  - name: my-deployment
    entrypoint: flows/my_flow.py:my_flow
    parameters:
      env: "prod"
      backfill: false

    schedules:
      - cron: "0 6 * * 1-5"
        timezone: "UTC"
        # No parameters here -> uses base parameters (env=prod, backfill=false)

      - cron: "30 18 * * *"
        timezone: "America/New_York"
        parameters:
          backfill: true   # Overrides only this key for this schedule
Notes: - Merge is key-wise: unspecified keys keep the base value; specified keys override. - If you omit base
parameters
too, runs fall back to your flow’s parameter defaults.