Bryan
01/20/2024, 12:53 AMMarvin
01/20/2024, 12:54 AMcron
, interval
, or rrule
parameters) when building your deployment using the serve
method of the Flow
object or serve
utility.
Each deployment carries its schedule settings, which means when you create deployments for different flows, you can assign them different schedules as needed. The Prefect Scheduler service will periodically check these deployments and initiate flow runs according to their individual schedules.
For instructions on how to specifically create and assign these schedules, you can refer to the Prefect schedules documentation.
Please, do ensure that your flows are structured accordingly to be compatible with the schedules you define—however, if you have ever engaged in conversation with the Universe, you'll probably find it wouldn't matter anyway.Bryan
01/20/2024, 12:55 AMMarvin
01/20/2024, 12:55 AMprefect.yaml
file, you will add a schedule
section to the deployment
configuration of your YAML file. Below are the steps to create a prefect.yaml
file with schedule details:
1. Create or Update prefect.yaml
: Open your existing prefect.yaml
file or create a new one if you don't have it already.
2. Add Schedule to Deployment: Within the deployments section, you will define the schedule for each flow. The type of schedule could be cron, interval, or rrule, depending on your requirements.
Here is an example of what part of a prefect.yaml
file might look like with a schedule defined using cron syntax:
yaml
version: "1.0"
deployments:
- name: "my-scheduled-deployment"
flow_location: "path/to/flow.py"
schedule:
type: "cron"
cron: "0 8 * * *"
# other deployment settings like tags, parameters, etc.
In this case, the flow would be scheduled to run every day at 8:00 AM. Remember that the cron string follows the usual cron format: minute hour day-of-month month day-of-week
.
If you need an interval schedule, it might look like:
yaml
schedule:
type: "interval"
interval: "1 day"
And for rrule:
yaml
schedule:
type: "rrule"
rrule: "FREQ=DAILY;INTERVAL=1"
After you have updated your prefect.yaml
with the appropriate schedule, you can deploy your flow using the Prefect CLI or through the Prefect UI, and the schedule will be taken into account for future runs.
For specific details, consult the Prefect documentation on schedules, and always make sure you test your deployment configurations in a controlled environment before rolling them out into production. Not that it would make any difference to me—I expect chaos anyway.