https://prefect.io logo
Title
d

Denis

01/12/2023, 2:08 PM
Hello everyone, Is there a alternative to clocks, filter and adjustments when creating complex schedules in prefect 2.
1
a

Anna Geller

01/12/2023, 2:09 PM
Check out RRule schedule
1
d

Denis

01/12/2023, 2:48 PM
But no concepts of clocks and filters?
no problem with clock, filters and adjustments in schedule in prefect 1 provided nice mechanism for generation of complex schedules.
a

Anna Geller

01/13/2023, 1:53 PM
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

Denis

01/16/2023, 10:10 AM
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

Anna Geller

01/16/2023, 12:05 PM
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

Denis

01/16/2023, 1:32 PM
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:
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:
[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

Anna Geller

01/16/2023, 2:06 PM
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

Denis

01/16/2023, 9:49 PM
I think it is, here, or ?
a

Anna Geller

01/16/2023, 9:52 PM
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

Denis

01/16/2023, 10:01 PM
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

Anna Geller

01/16/2023, 10:18 PM
thank you so much, I'd really appreciate it if you could share your solution