blob: d0dacdb76966ef8575f80879436e5b5bad46fce7 [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, follow_task_ids_if_false, target_lower, target_upper, use_task_execution_date = 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``.
: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``.
:param target_lower: target lower bound.
:param target_upper: target upper bound.
: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.
.. py:method:: choose_branch(self, context)
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()
.. py:function:: target_times_as_dates(base_date, lower, upper)
Ensures upper and lower time targets are datetimes by combining them with base_date