Is there a way to have 2 different schedule patter...
# prefect-community
m
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
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
@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
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
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
no unfortunately the filters are overlays across the whole schedule, independent of clock
m
gotcha
c
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
sounds good! thanks Chris - and thanks Marvin 😉
marvin 1