woom.iters.Cycle

woom.iters.Cycle#

class woom.iters.Cycle(begin_date, end_date=None, horizon=None)[source]#

Container for a time cycle

A Cycle represents either a point in time (single date) or a time interval (begin and end dates). Cycles are used to organize workflow execution over different time periods.

Parameters:
  • begin_date (date-like) – The start date of the cycle

  • end_date (date-like, optional) – The end date of the cycle. If None, the cycle represents a single point in time.

  • horizon (timedelta-like, optional) – Forecast horizon. When set on a single-date cycle (end_date=None), sets end_date = begin_date + horizon so that cycle_end_date and cycle_duration are available in templates without making is_interval True.

Notes

Cycles support equality comparison with flexible semantics:

  • Two cycles are equal if they have the same begin_date and end_date

  • A single date cycle equals an interval cycle if they share the same begin_date

  • Cycles can be compared with ISO 8601 formatted strings

Examples

>>> from woom.iters import Cycle
>>> # Single date cycles
>>> c1 = Cycle("2020-01-01")
>>> c2 = Cycle("2020-01-01")
>>> c1 == c2
True
>>> # Interval cycles
>>> i1 = Cycle("2020-01-01", "2020-01-10")
>>> i2 = Cycle("2020-01-01", "2020-01-10")
>>> i1 == i2
True
>>> # Mixed comparison - compared by begin_date
>>> c1 == i1
True
>>> # String comparison
>>> c1 == "2020-01-01T00:00:00+00:00"
True
__init__(begin_date, end_date=None, horizon=None)[source]#

Attributes

begin_date

Begin date (WoomDate)

date

Same as begin_date

is_interval

Whether it is an interval or a single date (bool)

is_first

Whether it is the first cycle (bool)

is_last

Whether it is the last cycle (bool)

horizon

Forecast horizon (Timedelta or None)

end_date

End date (WoomDate or None)

duration

Interval duration (Timedelta or None)

label

String used for for printing and based on the ISO 8601 format (str)

token

String used in file and directory names and based on the ISO 8601 format (str)

next

Next cycle (Cycle or None)

prev

Previous cycle (Cycle or None)

Methods

describe()

get_env_vars([suffix])

Export a dict of WOOM environment variables about this cycle

get_params([suffix])

Export a dict of substitution parameters about this cycle