Airflow Summit 2021 is coming July 8-16. Register now!

airflow.operators.datetime

Module Contents

class airflow.operators.datetime.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)[source]

Bases: 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: BranchDateTimeOperator

True branch will be returned when datetime.datetime.now() falls below target_upper and above target_lower.

Parameters
  • follow_task_ids_if_true (str or list[str]) – task id or task ids to follow if datetime.datetime.now() falls above target_lower and below target_upper.

  • follow_task_ids_if_false (str or list[str]) – task id or task ids to follow if datetime.datetime.now() falls below target_lower or above target_upper.

  • target_lower (Optional[datetime.datetime]) – target lower bound.

  • target_upper (Optional[datetime.datetime]) – target upper bound.

  • use_task_execution_date (bool) – If True, uses task’s execution day to compare with targets. Execution date is useful for backfilling. If False, uses system’s date.

choose_branch(self, context: Dict)[source]
airflow.operators.datetime.target_times_as_dates(base_date: datetime.datetime, lower: Union[datetime.datetime, datetime.time, None], upper: Union[datetime.datetime, datetime.time, None])[source]
Ensures upper and lower time targets are datetimes by combining them with base_date

Was this entry helpful?