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), setsend_date = begin_date + horizonso thatcycle_end_dateandcycle_durationare available in templates without makingis_intervalTrue.
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
Attributes
Begin date (
WoomDate)Same as
begin_dateWhether it is an interval or a single date (
bool)Whether it is the first cycle (
bool)Whether it is the last cycle (
bool)Forecast horizon (
Timedeltaor None)End date (
WoomDateor None)Interval duration (
Timedeltaor None)String used for for printing and based on the ISO 8601 format (
str)String used in file and directory names and based on the ISO 8601 format (
str)Next cycle (
Cycleor None)Previous cycle (
Cycleor 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