dstandish commented on code in PR #31628:
URL: https://github.com/apache/airflow/pull/31628#discussion_r1212306753
##########
airflow/models/dagrun.py:
##########
@@ -596,19 +596,18 @@ def recalculate(self) -> _UnfinishedStates:
unfinished = unfinished.recalculate()
leaf_task_ids = {t.task_id for t in dag.leaves}
- leaf_tis = [ti for ti in tis if ti.task_id in leaf_task_ids if
ti.state != TaskInstanceState.REMOVED]
- # TODO: Remove 'getattr' if setup/teardown is available for mapped task
+ leaf_tis = {ti for ti in tis if ti.task_id in leaf_task_ids if
ti.state != TaskInstanceState.REMOVED}
if dag.teardowns:
# when on_failure_fail_dagrun is `False`, the final state of the
DagRun
# will be computed as if the teardown task simply didn't exist.
- teardown_task_ids = [t.task_id for t in dag.teardowns]
- upstream_of_teardowns = [t.task_id for t in
dag.tasks_upstream_of_teardowns]
- teardown_tis = [ti for ti in tis if ti.task_id in
teardown_task_ids]
- on_failure_fail_tis = [ti for ti in teardown_tis if
getattr(ti.task, "on_failure_fail_dagrun")]
- tis_upstream_of_teardowns = [ti for ti in tis if ti.task_id in
upstream_of_teardowns]
- leaf_tis = list(set(leaf_tis) - set(teardown_tis))
- leaf_tis.extend(on_failure_fail_tis)
- leaf_tis.extend(tis_upstream_of_teardowns)
+ teardown_task_ids = {t.task_id for t in dag.teardowns}
+ upstream_of_teardowns = {t.task_id for t in
dag.tasks_upstream_of_teardowns}
+ teardown_tis = {ti for ti in tis if ti.task_id in
teardown_task_ids}
+ on_failure_fail_tis = {ti for ti in teardown_tis if
ti.task.on_failure_fail_dagrun}
+ tis_upstream_of_teardowns = {ti for ti in tis if ti.task_id in
upstream_of_teardowns}
+ leaf_tis -= teardown_tis
+ leaf_tis |= on_failure_fail_tis
+ leaf_tis |= tis_upstream_of_teardowns
Review Comment:
ok yeah, turns out a combination was required
`teardown_tis` was used two times, so it needed to be a set
the other two can be generator (and i did assign both of them to a variable
which i think is helpful from readability perspective and should have same
performance)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]