BranchDayOfWeekOperator

Use the BranchDayOfWeekOperator to branch your workflow based on week day value.

airflow/example_dags/example_branch_day_of_week_operator.pyView Source

dummy_task_1 = DummyOperator(task_id='branch_true', dag=dag)
dummy_task_2 = DummyOperator(task_id='branch_false', dag=dag)

branch = BranchDayOfWeekOperator(
    task_id="make_choice",
    follow_task_ids_if_true="branch_true",
    follow_task_ids_if_false="branch_false",
    week_day="Monday",
)

# Run dummy_task_1 if branch executes on Monday
branch >> [dummy_task_1, dummy_task_2]

Was this entry helpful?