You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit edc5fbb
Browse filesBrowse the repository at this point in the historyBrowse files
fixup! Add user-facing docs for the new Task Loops feature.
The loop docs only told readers what they could not do with a loop task's
output from outside the loop, and sent them to publish through a task outside
the loop without saying how that task would get the value. Reading the output
of a loop task from a task outside the loop now returns every iteration, so
describe that: how to refer to the loop task, the sequence the consumer gets,
the iteration-then-map-index order for a mapped task, and that a task using a
loop's output waits for the whole loop through the loop's gate, with what each
trigger rule then sees.
The limitations that still hold stay stated plainly: prior-date pulls cannot
select a loop iteration, and the wait API still rejects a loop member as the
result. Both now point at the recipe that works, a task outside the loop that
reads the sequence and returns what it needs.
Copy file name to clipboardExpand all lines: airflow-core/docs/authoring-and-scheduling/loops.rst
+54-2Lines changed: 54 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,12 @@ Iterations run one after another; task instances within an iteration can run in
37
37
If you are not sure whether you need a loop or mapped tasks, see
38
38
:ref:`loops-and-mapped-tasks`.
39
39
40
+
Before we go any further, it is worth addressing one thing: "How can you have
41
+
loops in a Dag, given Dag stands for Directed Acyclic Graph". The answer to that
42
+
is by being very careful. Essentially, there is no dependency loop introduced,
43
+
the tasks in the Dag still do form a cycle-free graph. The looping nature is
44
+
handled at runtime only.
45
+
40
46
Create a loop
41
47
=============
42
48
@@ -166,8 +172,8 @@ still running.
166
172
167
173
Limitations:
168
174
169
-
* ``include_prior_dates=True`` cannot select a loop iteration from another Dag run. Push the result to XCom through a task outside the loop if later Dag runs need to retrieve it with an ordinary XCom pull.
170
-
* The experimental DagRun wait API also requires an outside-loop result task. It rejects results selected directly from a loop member. See :ref:`dag-result`.
175
+
* ``include_prior_dates=True`` cannot select a loop iteration from another Dag run. Push the result to XCom through a task outside the loop if later Dag runs need to retrieve it with an ordinary XCom pull; see :ref:`loops-outside-result`.
176
+
* The experimental DagRun wait API also requires an outside-loop result task. Marking a loop member as the Dag result raises ``ValueError`` while the Dag is parsed, and the wait API rejects results selected directly from a loop member. Mark a task outside the loop as the result instead, for example one that returns the last element of a loop task's results. See :ref:`dag-result`.
171
177
172
178
Connect a loop to other tasks
173
179
=============================
@@ -182,6 +188,52 @@ With the default ``all_success`` trigger rule, ``finished`` waits for successful
182
188
loop completion. Other trigger rules behave normally; ``always`` does not wait
183
189
for the loop.
184
190
191
+
.. _loops-outside-result:
192
+
193
+
Use a loop's result outside the loop
194
+
====================================
195
+
196
+
A task outside the loop can read the output of a task inside it. Refer to the
197
+
loop task through the loop object and pass its output as an argument:
0 commit comments