AirFlow: How to set large number of external dependencies in one line? AirFlow: How to set large number of external dependencies in one line? hadoop hadoop

AirFlow: How to set large number of external dependencies in one line?


You can create your sensors in a loop and set dependencies within it. I think it's cleaner, but I'm not sure if that meets your requirement regarding amount of code as number of dependencies increase.

Example:

dependencies = [('dag1', 'task1'), ('dag2', 'task4'), ('dag2', 'task5'), ('dag3', 'task2')]other_task = PythonOperator(...)for dag_id, task_id in dependencies:    sensor = ExternalTaskSensor(        task_id='wait_for_{0}.{1}'.format(dag_id, task_id),        external_dag_id=dag_id,        external_task_id=task_id,        dag=dag)    sensor >> other_task