My idea is to have a task foo
which generates a list of inputs (users, reports, log files, etc), and a task is launched for every element in the input list. The
At this point in time, airflow does not support adding/removing a task while the dag is running.
The workflow order will be whatever is evaluated at the start of the dag run.
See the second paragraph here.
This means you cannot add/remove tasks based on something that happens in the run. You can add X tasks in a for loop based on something not related to the run, but after the run has begun there is no changing the workflow shape/order.
Many times you can instead use a BranchPythonOperator
to make a decision during a dag run, (and these decisions can be based on your xcom
values) but they must be a decision to go down a branch that already exists in the workflow.
Dag runs, and Dag definitions are separated in airflow in ways that aren't entirely intuitive, but more or less anything that is created/generated inside a dag run (xcom
, dag_run.conf
, etc.) is not usable for defining the dag itself.