I can't find the documentation for branching in Airflow's TaskFlowAPI. I tried doing it the "Pythonic" way, but when ran, the DAG does not see task_2_execute_if_true
, regardless of truth value returned by the previous task.
@dag(
schedule_interval=None,
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
catchup=False,
tags=['test'],
)
def my_dag():
@task()
def task_1_returns_boolean():
# evaluate and return boolean value
return boolean_value
@task()
def task_2_execute_if_true():
# do_something...
outcome_1 = task_1_returns_boolean()
if outcome_1:
outcome_2 = task_2_execute_if_true()
executed = my_dag()
What is the proper way of branching in TaskFlowAPI? Should I add one more function specifically for branching?