0
0
Apache Airflowdevops~10 mins

ExternalTaskSensor for cross-DAG dependencies in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the ExternalTaskSensor from Airflow sensors.

Apache Airflow
from airflow.sensors.external_task import [1]
Drag options to blanks, or click blank then click option'
AExternalTaskSensor
BExternalSensorTask
CTaskSensorExternal
DExternalTask
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong class names like ExternalSensorTask or ExternalTask.
2fill in blank
medium

Complete the ExternalTaskSensor to wait for a task named 'task_b' in DAG 'dag_b'.

Apache Airflow
wait_for_task = ExternalTaskSensor(
    task_id='wait_for_task_b',
    external_dag_id='[1]',
    external_task_id='task_b',
    mode='reschedule'
)
Drag options to blanks, or click blank then click option'
Atask_a
Bdag_a
Cdag_b
Dtask_b
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing external_dag_id with external_task_id.
3fill in blank
hard

Fix the error in the ExternalTaskSensor mode parameter to avoid blocking the worker.

Apache Airflow
wait_for_task = ExternalTaskSensor(
    task_id='wait_for_task_c',
    external_dag_id='dag_c',
    external_task_id='task_c',
    mode='[1]'
)
Drag options to blanks, or click blank then click option'
Apoke
Breschedule
Cblock
Dwait
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'poke' mode which blocks the worker.
4fill in blank
hard

Fill both blanks to create an ExternalTaskSensor that waits for 'task_x' in 'dag_x' with a 600 seconds timeout.

Apache Airflow
wait_task = ExternalTaskSensor(
    task_id='wait_task_x',
    external_dag_id='[1]',
    external_task_id='[2]',
    timeout=600
)
Drag options to blanks, or click blank then click option'
Adag_x
Btask_x
Cdag_y
Dtask_y
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping DAG and task names.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps task ids to their ExternalTaskSensor instances for tasks 'task1' and 'task2' in 'dag_main'.

Apache Airflow
sensors = {
    '[1]': ExternalTaskSensor(
        task_id='wait_[1]',
        external_dag_id='[2]',
        external_task_id='[1]'
    )
    for [3] in ['task1', 'task2']
}
Drag options to blanks, or click blank then click option'
Atask
Bdag_main
Ctask_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.