Skip to content

Instantly share code, notes, and snippets.

@Arqentum
Created October 3, 2023 17:50
Show Gist options
  • Select an option

  • Save Arqentum/9eda7373ecc05e482da8dff35d469feb to your computer and use it in GitHub Desktop.

Select an option

Save Arqentum/9eda7373ecc05e482da8dff35d469feb to your computer and use it in GitHub Desktop.
#Airflow task branching
month_mid = DummyOperator(task_id='month_mid')
month_end = DummyOperator(task_id='month_end')
def choose_branch(execution_date, **_):
if execution_date.day == 15:
return month_mid.task_id
else:
return month_end.task_id
branching_step = BranchPythonOperator(
task_id='branching_step',
python_callable=choose_branch
)
wait_for_ingest >> branching_step >> month_mid >> day_tasks >> final_step
wait_for_ingest >> branching_step >> month_end >> month_tasks >> final_step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment