Hello, I have a question regarding scheduling (exc...
# prefect-community
c
Hello, I have a question regarding scheduling (exceptions)
āœ… 1
How do I stop a flow from running on certain specified days?
In Prefect 1, I could specify a [list] of datetime objects, where the objects refer to days that I do not want the flows to run This list is passed as an argument to
prefect.schedules.filters
.
In Prefect 2 (Orion), I am not sure where to specify exceptions. The available schedulers are rrule and cron. I have not tried rrule so far, but AFAIK there is no way to pass a custom list of datetime objects as cron exceptions. An example is that I have a script that runs every morning at 9am Mon-Sat, but I need that script to stop running on specified holidays.
r
c
Hey I tried to use rrule in my deployment schedule: rrule: 'FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR,SA;EXDATE=2023-03-23,2023-04-22,2023-09-16,2023-06-05,2023-01-22,2023-05-01,2023-11-12,2023-12-25,2023-08-31,2023-04-23,2023-01-23' And got the error: 'msg': 'Invalid RRule string "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR,SA;EXDATE=2023-03-23,2023-04-22,2023-09-16,2023-06-05,2023-01-22,2023-05-01,2023-11-12,2023-12-25,2023-08-31,2023-04-23,2023-01-23": unknown parameter \'EXDATE\'', 'type': 'value_error'}])
r
c
Ahh i was on 2.4.0, now upgraded to 2.7.4, but still encountering unknown parameter EXDATE
r
c
Thank you very much kind sir!
šŸ‘ 1
āœØ 1
After reading the tests, I thought I needed to add timezones to the excluded dates: i.e.
Copy code
schedule:
  rrule: 'EXDATE:20230323' --> Needs to be expressed as: EXDATE: 20230323T000000Z
  timezone: Asia/Singapore
It turns out that
YYYYMMDD
works, however, the error in the rrule is that it needs to be specified as
EXDATE:
instead of
EXDATE=
I was able to apply the above schedule to my deployment, but does not fit my needs, as I need the flow to: ā€¢ Run everyday at 430pm ā€¢ Excluding specified dates Adding the first requirement to the rrule:
Copy code
schedule:
  rrule: 'EXDATE:20230323;FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA;BYHOUR=16;BYMINUTE=30'
  timezone: Asia/Singapore
The error encountered is: Invalid string (replacing
':'
with
'='
or vice versa for the other properties
FREQ
,
BYDAY
,
BYHOUR
, `BYMINUTE`does not work as well). I also tried combining the rrule (using its
EXDATE
property) with a cron expression, but that didn't work either.
Copy code
schedule:
  rrule: 'EXDATE:20230323'
  cron: 5 9 * * 1-6
  timezone: Asia/Singapore
  day_or: true