Jeff Kehler
05/06/2022, 6:40 AMIntervalClock
scheduler. If i were to pass interval=timedelta(hours=1)
to schedule a run for every hour, would this be scheduled to occur at the beginning of every hour? Or would it be relative to when I register the Flow? eg if I register the flow at 1:13pm then the IntervalClock
would trigger at 13 minutes past the hour every hour? Or would it just kick off at the first minute of every hour?Anna Geller
05/06/2022, 9:42 AMfrom datetime import time, timedelta
import pendulum
from prefect.schedules import Schedule
from prefect.schedules.clocks import IntervalClock
from prefect.schedules.filters import between_times, is_weekday
clock = IntervalClock(
start_date=pendulum.datetime(2022, 5, 12, 9, 0, tz="Europe/London"),
interval=timedelta(hours=1),
)
schedule = Schedule(clocks=[clock])
for sched in schedule.next(20):
print(sched)
from prefect.schedules import CronSchedule
schedule = CronSchedule(
cron="0 9 * * *"
)
but you can also pass a start date here:
from prefect.schedules import CronSchedule
schedule = CronSchedule(
cron="0 9 * * *", start_date=pendulum.datetime(2022, 1, 12, 0, 0, tz="America/New_York")
)