Complete the code to import the BranchPythonOperator from Airflow.
from airflow.operators.[1] import BranchPythonOperator
The BranchPythonOperator is imported from airflow.operators.python module.
Complete the code to define the branch function that decides the next task.
def choose_branch(): if condition: return [1] else: return 'task_b'
The branch function must return the task_id as a string, so it should be quoted.
Fix the error in the BranchPythonOperator instantiation by completing the missing argument.
branch_task = BranchPythonOperator(
task_id='branching',
python_callable=[1],
dag=dag
)The python_callable argument expects a function object, not a call or string.
Fill both blanks to set dependencies so branch_task runs before task_a and task_b.
branch_task [1] task_a branch_task [2] task_b
The '>>' operator sets downstream dependencies in Airflow, so branch_task runs before task_a and task_b.
Fill all three blanks to create a DAG with BranchPythonOperator and two downstream tasks.
with DAG('branch_dag', start_date=days_ago(1)) as dag: branch_task = BranchPythonOperator( task_id=[1], python_callable=[2] ) task_a = DummyOperator(task_id='task_a') task_b = DummyOperator(task_id='task_b') branch_task [3] task_a branch_task >> task_b
The BranchPythonOperator needs a task_id string and a python_callable function. The dependency operator '>>' sets branch_task before task_a.