简体   繁体   中英

Dynamically generate a DAG during a DAG Run - Airflow

I'd like to know if you can easily, dynamically generate a DAG within a DAG run, like:

DAG A would be:

  1. Do some data computations
  2. Based on the previous result generate DAG B
  3. Load DAG B into the airflow DagBag
  4. TriggerDagRunOperator for DAG B
  5. ExternalTaskSensor on last DAG B task.

Cheers,

This is possible. You would need to generate a file that, when parsed generates DAG B. You could not just generate a DAG object as part of DAG A. You will need write access to the DagBag folder across all your Airflow components (scheduler, webserver, and workers). Also, allow some time for the DAG B file to be parsed before triggering it with TriggerDagRun Operator.

All of this is a little hacky. AIP-42 is being worked on that will allow for modifying the tasks within a DAG based on other results which I think will help you get the desired effect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM