pypi prefect 2.16.1
Release 2.16.1

latest releases: 3.1.2, 3.1.2.dev2, 3.1.2.dev1...
8 months ago

Enhanced multiple schedule support 📅

prefect.yaml now supports specifying multiple schedules via the schedules key.

This allows you to define multiple schedules for a single deployment, and each schedule can have its own cron, interval, or rrule configuration:

 ...
 schedules:
    - cron: "0 0 * * *"
      active: false
    - interval: 3600
      active: true
    - rrule: "FREQ=YEARLY"
      active: true

In addition you can specify multiple schedules via arguments to prefect deploy:

prefect deploy ... --cron '4 * * * *' --cron '1 * * * *' --rrule 'FREQ=DAILY'

More detail

We've also added support for multiple schedules to flow.serve, flow.deploy and prefect.runner.serve. You can provide multiple schedules by passing a list to the cron, interval, or rrule arguments:

import datetime
import random

from prefect import flow


@flow
def trees():
    tree = random.choice(["🌳", "🌴", "🌲", "🌵"])
    print(f"Here's a happy little tree: {tree}")

if __name__ == "__main__":
    trees.serve(
        name="trees",
        interval=[3600, 7200, 14400],
    )

This will create a deployment with three schedules, one that runs every hour, one that runs every two hours, and one that runs every four hours. For more advanced cases, use the schedules argument.

    trees.serve(
        name="trees",
        schedules=[
            IntervalSchedule(interval=datetime.timedelta(minutes=30)),
            {"schedule": RRuleSchedule(rrule="FREQ=YEARLY"), "active": True},
            MinimalDeploymentSchedule(schedule=CronSchedule(cron="0 0 * * *"), active=False),
        ]
    )

Dive into these new scheduling capabilities today and streamline your workflows like never before.

For implementation details, see the following pull request:
- #12107

New Contributors 🌟

  • Shoutout to @jrbourbeau for their first contribution!

See the release notes for more details!

Don't miss a new prefect release

NewReleases is sending notifications on new releases.