Member-only story

ExternalTaskSensor vs TriggerDagRunOperator

Obinna Onyema
Towards Data Engineering
8 min readSep 28, 2024

Not a Medium member? Click here to read for free.

I have been exploring airflow sensors and deferrable operators in my recent articles. In the last article, I wrote about how to Create Event Driven Airflow Pipeline with SNS, SQS and Lambda which was a sequel to Create Event Driven Airflow Pipeline with Amazon SQS.

In this article, I want to answer more queries that look like these:

  • How to trigger Airflow DAG on the success of another DAG
  • How to pause Airflow DAG until another DAG is completed
  • How to trigger Airflow DAG from another DAG with config
  • How to use TriggerDagRunOperator with dynamic tasks

This time around, I will use the TriggerDagRunOperator and ExternalTaskSensor classes.

TriggerDagRunOperator

The simplest way to use this is to provide it with the DAG ID for the target DAG.

# ets_vs_tdr_trigger
trigger_task = TriggerDagRunOperator(
task_id='trigger_task_1',
trigger_dag_id='ets_vs_tdr_receiver'
)

I am starting by setting up two DAGs: ets_vs_tdr_trigger will be used to trigger ets_vs_tdr_receiver.

Using Custom Run ID

When I use triggers like this, I like to customize the run ID in the target DAG so that when looking through DAG runs later on I know whether this DAG was a…

--

--

Towards Data Engineering
Towards Data Engineering

Published in Towards Data Engineering

Dive into data engineering with top Medium articles on big data, cloud, automation, and DevOps. Follow us for curated insights and contribute your expertise. Join our thriving community of professionals and enthusiasts shaping the future of data-driven solutions.

Obinna Onyema
Obinna Onyema

Written by Obinna Onyema

Enjoying building solutions with data and AI. Machine Learning Researcher https://www.linkedin.com/in/obinna-onyema/

No responses yet

Write a response