Let's say you have two Capos DAGs. How would you create a dependency so that DAG A must finish before DAG B starts?
1Times asked
Apr 2026Last seen
Apr 2026First seen
💡 Model Answer
In Airflow you can enforce that DAG B waits for DAG A to finish by using an ExternalTaskSensor in DAG B. The sensor references the upstream DAG ID and the task ID (or the DAG run) you want to wait for. Example:
python
from airflow import DAG
from airflow.sensors.external_task_sensor import ExternalTaskSensor
from datetime import datetime
with DAG('dag_b', start_date=datetime(2024,1,1), schedule_interval='@daily') as dag:
wait_for_a = ExternalTaskSensor(
task_id='wait_for_dag_a',
external_dag_id='dag_a',
external_task_id='final_task_in_a',
mode='poke',
timeout=600,
poke_interval=30
)
# downstream tasksAlternatively, you can use trigger_dag to programmatically start DAG B from DAG A’s final task, or set depends_on_past=True and use a shared XCom flag. The ExternalTaskSensor is the simplest declarative way to enforce the finish‑before‑start rule without modifying the upstream DAG.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500