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:
yaml
...
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'`
<details>
<summary>More detail</summary>
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:
python
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.
python
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.
</details>
For implementation details, see the following pull request:
- https://github.com/PrefectHQ/prefect/pull/12107
New Contributors 🌟
- Shoutout to jrbourbeau for their first contribution!
<hr>
See the [release notes](https://github.com/PrefectHQ/prefect/blob/main/RELEASE-NOTES.md#release-2161) for more details!