https://prefect.io logo
Title
p

Priyank

06/13/2022, 11:14 AM
Hi all, how can I skip all the tasks in the flow if there is holiday on that day or any particular date? Assuming I already have a list of holidays. What can be the best approach?
1
a

Anna Geller

06/13/2022, 11:16 AM
Is it Prefect 2.0 or 1.0 question?
p

Priyank

06/13/2022, 11:19 AM
1.0
a

Anna Geller

06/13/2022, 11:30 AM
you can use not_filters to exclude holidays:
from prefect.schedules import filters, clocks, schedules
from datetime import timedelta

list_of_holidays = []  # list of datetime objects

sched = schedules.Schedule(
    # fire every hour
    clocks=[clocks.IntervalClock(timedelta(hours=1))],
    # but only on weekdays
    filters=[filters.is_weekday],
    # exclude holidays
    not_filters=list_of_holidays,
)
👍 1