Schedules

To schedule a flow with a flow manager, users must specify a Schedule that an associated flow should be run on. The base Schedule class allows users to specify this by providing a function to check whether the flow should be run, given the current time:

class flow.schedule.Schedule

A schedule that determines when an associated flow should run.

__init__(check_time: Callable[[datetime], bool]) None

Initialize the schedule with a member to check the time.

Parameters:

check_time (Callable[[datetime], bool]) – A function that takes in the current time, and determines whether the flow should be run. This function can assume that the given time is rounded to the nearest minute

__add__(other: Schedule) Schedule

Add two schedules to get the union of the two schedules.

Parameters:

other (Schedule) – The other schedule to add to

Returns:

The union of the two schedules

Return type:

Schedule

__sub__(other: Schedule) Schedule

Subtract two schedules to get the difference of the two schedules.

Parameters:

other (Schedule) – The other schedule to subtract from the current

Returns:

The difference of the two schedules

Return type:

Schedule

In addition, helper children classes are implemented for common schedule patterns:

class flow.schedule.Always

A schedule to always run a flow.

__init__() None

Initialize the schedule to always run.

class flow.schedule.Hourly

A schedule to run a flow each hour.

__init__() None

Initialize the hourly schedule.

class flow.schedule.Daily

A schedule to run a flow once a day.

__init__(hour: int) None

Initialize the daily schedule with the specified hour.

Parameters:

hour (int) – The hour to run on in 24-hour time (0-23)

class flow.schedule.Weekly

A schedule to run a flow once a week.

__init__(day: str, hour: int) None

Initialize the weekly schedule with the specified hour and day.

Parameters:
  • day (str) – The day of the week to run on

  • hour (int) – The hour to run on in 24-hour time (0-23)