blob: 028f47f73f90ffed3dbe566a0757716e05b8fd9a [file] [log] [blame]
:py:mod:`airflow.operators.datetime`
====================================
.. py:module:: airflow.operators.datetime
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.operators.datetime.BranchDateTimeOperator
Functions
~~~~~~~~~
.. autoapisummary::
airflow.operators.datetime.target_times_as_dates
.. py:class:: BranchDateTimeOperator(*, follow_task_ids_if_true: Union[str, Iterable[str]], follow_task_ids_if_false: Union[str, Iterable[str]], target_lower: Union[datetime.datetime, datetime.time, None], target_upper: Union[datetime.datetime, datetime.time, None], use_task_execution_date: bool = False, **kwargs)
Bases: :py:obj:`airflow.operators.branch.BaseBranchOperator`
Branches into one of two lists of tasks depending on the current datetime.
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:BranchDateTimeOperator`
True branch will be returned when ``datetime.datetime.now()`` falls below
``target_upper`` and above ``target_lower``.
:param follow_task_ids_if_true: task id or task ids to follow if
``datetime.datetime.now()`` falls above target_lower and below ``target_upper``.
:type follow_task_ids_if_true: str or list[str]
:param follow_task_ids_if_false: task id or task ids to follow if
``datetime.datetime.now()`` falls below target_lower or above ``target_upper``.
:type follow_task_ids_if_false: str or list[str]
:param target_lower: target lower bound.
:type target_lower: Optional[datetime.datetime]
:param target_upper: target upper bound.
:type target_upper: Optional[datetime.datetime]
:param use_task_execution_date: If ``True``, uses task's execution day to compare with targets.
Execution date is useful for backfilling. If ``False``, uses system's date.
:type use_task_execution_date: bool
.. py:method:: choose_branch(self, context: Dict) -> Union[str, Iterable[str]]
Subclasses should implement this, running whatever logic is
necessary to choose a branch and returning a task_id or list of
task_ids.
:param context: Context dictionary as passed to execute()
:type context: dict
.. py:function:: target_times_as_dates(base_date: datetime.datetime, lower: Union[datetime.datetime, datetime.time, None], upper: Union[datetime.datetime, datetime.time, None])
Ensures upper and lower time targets are datetimes by combining them with base_date