Hello everyone, Is there a alternative to clocks...
# ask-community
d
Hello everyone, Is there a alternative to clocks, filter and adjustments when creating complex schedules in prefect 2.
1
a
Check out RRule schedule
1
d
But no concepts of clocks and filters?
m
This solves your clocks problem no?
message has been deleted
d
no problem with clock, filters and adjustments in schedule in prefect 1 provided nice mechanism for generation of complex schedules.
a
thanks Denis, I agree it was a nice interface. but RRule is helpful for generating the whole deployment spec via API call (no client dependencies), so there are tradeoffs. is there some schedule that you can't figure out with RRule? we definitely need more examples for rrule
d
Recent limitation with MAX_RRULE_LENGTH forced us to create some more complex schedules in order to decrease rrule length. So right now we're thinking just to switch back and for using EXDATE and RDATE when it's appropriate. This was just nice feature that we could use without creating some custom logic.
a
gotcha, it seems like you are creating several custom scheduled dates, rather than a recurring interval, correct? perhaps then looping over those dates with the run_deployment utility would be easier?
d
they are recurring but with custom pandas offsets. Anyway I am trying to use
RRuleSchedule.from_rrule(rrule_set)
and in one specific case, I use
dateutil.rruleset()
to set only rdates with timezone, but as I see from_rrule method only takes timezone from dtstart which is specified in dateutil.rrule, but in that case I need to define frequency which I don't want as it generates unnecessary dates and makes rrule string longer. To be more clear for following I expected output to be the same from this code:
Copy code
rrule_set=rrule.rruleset()
rrule_set.rdate(pendulum.DateTime(2023,1,1,tzinfo=pendulum.timezone("Europe/Sarajevo")))
rrule_set.rdate(pendulum.DateTime(2023,2,1,tzinfo=pendulum.timezone("Europe/Sarajevo")))
rrule_set.rdate(pendulum.DateTime(2023,3,1,tzinfo=pendulum.timezone("Europe/Sarajevo")))
rrule_set.rdate(pendulum.DateTime(2023,4,1,tzinfo=pendulum.timezone("Europe/Sarajevo")))

pp(list(rrule_set))
dates=await RRuleSchedule.from_rrule(rrule_set).get_dates(n=10,start=pendulum.DateTime(2023,1,1,tzinfo=pendulum.timezone("Europe/Sarajevo")))
dates
output:
Copy code
[DateTime(2023, 1, 1, 0, 0, 0, tzinfo=Timezone('Europe/Sarajevo')),
 DateTime(2023, 2, 1, 0, 0, 0, tzinfo=Timezone('Europe/Sarajevo')),
 DateTime(2023, 3, 1, 0, 0, 0, tzinfo=Timezone('Europe/Sarajevo')),
 DateTime(2023, 4, 1, 0, 0, 0, tzinfo=Timezone('Europe/Sarajevo'))]
***************************
[DateTime(2023, 1, 1, 0, 0, 0, tzinfo=Timezone('UTC')),
 DateTime(2023, 2, 1, 0, 0, 0, tzinfo=Timezone('UTC')),
 DateTime(2023, 3, 1, 0, 0, 0, tzinfo=Timezone('UTC')),
 DateTime(2023, 4, 1, 0, 0, 0, tzinfo=Timezone('UTC'))]
My question is I guess, is this intended behavior, in order to force dtstart to be defined or ..?
a
rrule set is not supported afaik when you say offset, do you mean just CET timezone?
we do support timezone in the interval schedule
d
I think it is, here, or ?
a
Hmm I don't know, rrule is mainly supposed to be used in a way that it can be passed as a string to the API call If this rrule set story doesn't work for you as expected, I'd recommend creating a minimal reproducible example, opening a GitHub issue and sharing the link here
d
Yeah I ended up building rrule string then passing it, it would be nice just to use dateutil.rruleset though. After I am finished with testing will probably post it on github, it's mostly just leveraging what is already there. Thanks!!
💯 1
gratitude thank you 1
a
thank you so much, I'd really appreciate it if you could share your solution