bbovenzi commented on code in PR #74671:
URL: https://github.com/apache/airflow/pull/74671#discussion_r4275633172
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -442,21 +442,43 @@ def _build_ti_summaries(
if isinstance(group, SerializedLoopTaskGroup)
}
regions = DynamicRegion.load_for_run(dag_id, run_id, session=session) if
loop_ids else {}
- for ti in chain([first], rows):
+ positions_by_ti = [
+ (
+ ti,
+ {
+ loop_id: position
+ for loop_id in loop_ids
+ if (position := loop_position(regions, ti.region_id,
ti.region_index, loop_id)) is not None
+ },
+ )
+ for ti in chain([first], rows)
+ ]
+ # A looped task has one row per iteration. Counting them all would report
the work done
+ # across the whole loop rather than the state the task is in, so the state
counts come from
+ # the newest iteration of each invocation. Every iteration still feeds
loop_iterations,
+ # which is what reports how many ran.
+ latest_iteration: dict[tuple[str, str, UUID], int] = {}
+ for ti, positions in positions_by_ti:
+ for loop_id, (family_id, iteration) in positions.items():
+ key = (ti.task_id, loop_id, family_id)
+ if iteration > latest_iteration.get(key, -1):
+ latest_iteration[key] = iteration
+ for ti, positions in positions_by_ti:
summary = ti_details.get(ti.task_id)
if summary is None:
summary = ti_details[ti.task_id] = GridNodeAgg()
- loop_positions = {}
- for loop_id in loop_ids:
- if position := loop_position(regions, ti.region_id,
ti.region_index, loop_id):
- loop_positions[loop_id] = position
summary.add_ti(
state=ti.state,
start_date=ti.start_date,
end_date=ti.end_date,
dag_version_number=getattr(ti, "version_number", None),
has_note=bool(getattr(ti, "has_note", False)),
- loop_positions=loop_positions,
+ loop_positions=positions,
+ region=(ti.region_id, ti.region_index) if positions else None,
Review Comment:
Going to improve in a follow up
--
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]