pipeline.src.shared_tasks.dates =============================== .. py:module:: pipeline.src.shared_tasks.dates Classes ------- .. autoapisummary:: pipeline.src.shared_tasks.dates.TimeUnit Functions --------- .. autoapisummary:: pipeline.src.shared_tasks.dates.get_utcnow pipeline.src.shared_tasks.dates.date_trunc pipeline.src.shared_tasks.dates.get_current_year pipeline.src.shared_tasks.dates.get_timezone_aware_utcnow pipeline.src.shared_tasks.dates.make_timedelta pipeline.src.shared_tasks.dates.make_relativedelta pipeline.src.shared_tasks.dates.make_periods Module Contents --------------- .. py:class:: TimeUnit(*args, **kwds) Bases: :py:obj:`enum.Enum` Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access:: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: YEAR :value: 'YEAR' .. py:attribute:: MONTH :value: 'MONTH' .. py:attribute:: DAY :value: 'DAY' .. py:attribute:: HOUR :value: 'HOUR' .. py:attribute:: MINUTE :value: 'MINUTE' .. py:attribute:: SECOND :value: 'SECOND' .. py:function:: get_utcnow() Task version of `datetime.utcnow` .. py:function:: date_trunc(d: datetime.datetime, unit: str) .. py:function:: get_current_year() -> int Returns current year .. py:function:: get_timezone_aware_utcnow() .. py:function:: make_timedelta(**kwargs) -> datetime.timedelta Task version of `datetime.timedelta` .. py:function:: make_relativedelta(**kwargs) -> datetime.timedelta Task version of `dateutil.relativedelta` .. py:function:: make_periods(start_hours_ago: int, end_hours_ago: int, minutes_per_chunk: int, chunk_overlap_minutes: int) -> List[src.helpers.dates.Period] `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.