https://prefect.io logo
m

Mitchell Bregman

02/10/2021, 7:31 PM
Is there a way to have 2 different schedule patterns attached to a single flow. For example, I want this flow to run on a 5 minute interval during business hours only, and on an hourly interval off business hours.
👍 1
c

Chris White

02/10/2021, 7:34 PM
Hey Mitchell - this is definitely possible using individual Clocks with filters attached; in particular you’ll probably want to set up a
between_times
filter on each clock: https://docs.prefect.io/api/latest/schedules/filters.html#functions Clock types, filters, etc. can all be mix and matched in whatever way makes sense for your use case
👍 1
m

Mitchell Bregman

02/10/2021, 7:48 PM
@Chris White so that makes sense, but I’m confused on how you attach a filter to a specfic IntervalClock.. not seeing it in the API… are you saying:
Copy code
flow.schedule = Schedule(clocks=[IntervalClock(...), IntervalClock(...)])
where
is where
between_times
filter would go?
following up,
IntervalClocks
and
IntervalSchedule
both dont take in a filter param
The question becomes - how do you attach a filter to a clock?
c

Chris White

02/10/2021, 8:16 PM
Yea, I think I got ahead of myself… I thought filters could be attached to individual clocks but I agree that does not seem to be the case
m

Mitchell Bregman

02/10/2021, 8:23 PM
my next thought process is.. the list of clocks and list of filters; say my first clock is every 5 mins, and second clock is every hour… now if my first filter is weekday, and second filter is weekend, does it get matched to its respective clock?
i can build my own factory pattern for schedule choice certainly, but would rather use all built-ins
c

Chris White

02/10/2021, 8:25 PM
no unfortunately the filters are overlays across the whole schedule, independent of clock
m

Mitchell Bregman

02/10/2021, 8:26 PM
gotcha
c

Chris White

02/10/2021, 8:27 PM
I like this use case though, I actually think we could allow for filters to be attached to clocks as well as schedules — I’ll open an issue for us to discuss on / consider the implications
@Marvin open “Allow for filters to be configured on individual clocks”
m

Mitchell Bregman

02/10/2021, 8:27 PM
sounds good! thanks Chris - and thanks Marvin 😉
marvin 1