# Filters


Schedule filters are functions that accept a candidate datetime and return True if the candidate is valid, and False otherwise.

Filters have the signature Callable[[datetime], bool].

# Functions

top-level functions:                                                                                                                                                       

prefect.schedules.filters.at_time

(t)[source]

Filter that allows events that match a specific time.

For example, at_time(datetime.time(4)) would only allow runs at 4 AM in the given timezone.

Args:

  • t (time): the time to match
Returns:
  • Callable[[datetime], bool]: a filter function

prefect.schedules.filters.between_datetimes

(start, end)[source]

Filter that allows events between a start time and end time

Args:

  • start (datetime): the start datetime
  • end (datetime): the end datetime
Returns:
  • Callable[[datetime], bool]: a filter function

prefect.schedules.filters.between_dates

(start_month, start_day, end_month, end_day)[source]

Filter that allows events between specific dates in each year.

For example, between_dates(10, 15, 3, 31) would only allow dates between October 15 and March 31 in any year.

Args:

  • start_month (int): the starting month, as a number (1 = January)
  • start_day (int): the starting day, as a number
  • end_month (int): the ending month, as a number
  • end_day (int): the ending day, as a number
Returns:
  • Callable[[datetime], bool]: a filter function

prefect.schedules.filters.between_times

(start, end)[source]

Filter that allows events between a start time and end time

For example, between_times(start=datetime.time(14), end=datetime.time(16)) would only allow runs between the hours of 2 PM and 4 PM in the given timezone.

Args:

  • start (time): the start time
  • end (time): the end time
Returns:
  • Callable[[datetime], bool]: a filter function

prefect.schedules.filters.is_weekday

(dt)[source]

Filter that only allows events on weekdays

Args:

  • dt (datetime): the candidate datetime
Returns:
  • bool: True if the date is a weekday; False otherwise

prefect.schedules.filters.is_weekend

(dt)[source]

Filter that only allows events on weekends

Args:

  • dt (datetime): the candidate datetime
Returns:
  • bool: True if the date is a weekend; False otherwise

prefect.schedules.filters.is_day_of_week

(day_of_week)[source]

Filter that only matches on a specific day of the week.

Args:

  • day_of_week (int): the integer day of the week to match on (0 - 6 == Sunday - Saturday)
Returns:
  • Callable[[datetime], bool]: a filter function

prefect.schedules.filters.is_month_end

(dt)[source]

Filter that only allows events on the last day of the month

Args:

  • dt (datetime): the candidate datetime
Returns:
  • bool: True if the date is a month-end; False otherwise

prefect.schedules.filters.is_month_start

(dt)[source]

Filter that only matches on the first day of the month

Args:

  • dt (datetime): the candidate datetime
Returns:
  • bool: True if date is the first day of the month, False otherwise

This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC