pipeline.src.shared_tasks.dates
Classes
Create a collection of name/value pairs. |
Functions
Task version of datetime.utcnow |
|
|
|
|
Returns current year |
|
Task version of datetime.timedelta |
|
Task version of dateutil.relativedelta |
|
prefect.Task version of the function src.helpers.dates.make_periods, |
Module Contents
- class pipeline.src.shared_tasks.dates.TimeUnit(*args, **kwds)[source]
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- pipeline.src.shared_tasks.dates.make_timedelta(**kwargs) → datetime.timedelta[source]
Task version of datetime.timedelta
- pipeline.src.shared_tasks.dates.make_relativedelta(**kwargs) → datetime.timedelta[source]
Task version of dateutil.relativedelta
- pipeline.src.shared_tasks.dates.make_periods(start_hours_ago: int, end_hours_ago: int, minutes_per_chunk: int, chunk_overlap_minutes: int) → List[src.helpers.dates.Period][source]
prefect.Task version of the function src.helpers.dates.make_periods, with the difference that start and end dates are to be given as a number of hours from the current date (instead of datetime objects), and chunk duration and overlap are to be given as a number of minutes (instead of timedelta objects). This is to accomodate for the fact that Prefect flows’ parameters must be JSON-serializable, and datetime and timedelta are not, by default.
src.helpers.dates.make_periods is recursive, hence the construction as a python function first and not directly as Prefect Task.
See src.helpers.dates.make_periods for help.