pierrejeambrun commented on code in PR #64034:
URL: https://github.com/apache/airflow/pull/64034#discussion_r3014853797
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -118,6 +117,67 @@ def _get_serdag(dag_id, dag_version_id, session) ->
SerializedDagModel | None:
return serdag
+def _get_grid_run_dag_versions(
Review Comment:
We recently introduced `attach_dag_versions_to_runs` which achieve the same
I believe, can you use it here instead and remove this piece of code.
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -332,38 +384,77 @@ def get_grid_runs(
return_total_entries=False,
)
results = session.execute(dag_runs_select_filter).unique().all()
+ dag_versions_by_run_id = _get_grid_run_dag_versions(
+ dag_id=dag_id,
+ dag_runs=[run for run, _ in results],
+ session=session,
+ )
grid_runs = []
for run, has_missed in results:
- run.has_missed_deadline = has_missed
- grid_runs.append(GridRunsResponse.model_validate(run,
from_attributes=True))
+ grid_runs.append(
+ GridRunsResponse.model_validate(
+ {
+ "dag_id": run.dag_id,
+ "run_id": run.run_id,
+ "queued_at": run.queued_at,
+ "start_date": run.start_date,
+ "end_date": run.end_date,
+ "run_after": run.run_after,
+ "state": run.state,
+ "run_type": run.run_type,
+ "dag_versions": dag_versions_by_run_id[run.run_id],
+ "has_missed_deadline": has_missed,
+ }
+ )
+ )
return grid_runs
def _build_ti_summaries(
- dag_id: str, run_id: str, task_instances: Sequence, session, serdag:
SerializedDagModel | None = None
-) -> dict:
- ti_details: dict = collections.defaultdict(list)
+ dag_id: str,
+ run_id: str,
+ task_instances: Iterable[Any],
+ session: Session,
+ *,
+ serdag: SerializedDagModel | None = None,
Review Comment:
Is that `serdag` param used, it seems duplicated with the `serdag_cache`
--
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]