Skip to content

Commit

Permalink
AIP-84 Fix version_number in grid endpoint (apache#46323)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejeambrun authored Feb 1, 2025
1 parent 53963c6 commit a078cce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
3 changes: 1 addition & 2 deletions airflow/api_fastapi/core_api/datamodels/ui/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field

Expand Down Expand Up @@ -51,7 +50,7 @@ class GridDAGRunwithTIs(BaseModel):
run_type: DagRunType
data_interval_start: datetime | None
data_interval_end: datetime | None
version_number: UUID | None
version_number: int | None
note: str | None
task_instances: list[GridTaskInstanceSummary]

Expand Down
3 changes: 1 addition & 2 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8786,8 +8786,7 @@ components:
title: Data Interval End
version_number:
anyOf:
- type: string
format: uuid
- type: integer
- type: 'null'
title: Version Number
note:
Expand Down
11 changes: 7 additions & 4 deletions airflow/api_fastapi/core_api/routes/ui/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from fastapi import Depends, HTTPException, Request, status
from sqlalchemy import select
from sqlalchemy.orm import joinedload

from airflow import DAG
from airflow.api_fastapi.common.db.common import SessionDep, paginated_select
Expand Down Expand Up @@ -93,7 +94,9 @@ def grid_data(
base_query = (
select(DagRun)
.join(DagRun.dag_run_note, isouter=True)
.join(DagRun.dag_version, isouter=True)
.select_from(DagRun)
.options(joinedload(DagRun.dag_version))
.where(DagRun.dag_id == dag.dag_id)
)

Expand Down Expand Up @@ -212,11 +215,11 @@ def grid_data(
run_type=dag_run.run_type,
data_interval_start=dag_run.data_interval_start,
data_interval_end=dag_run.data_interval_end,
version_number=dag_run.dag_version_id,
version_number=dag_run.dag_version.version_number if dag_run.dag_version else None,
note=dag_run.note,
task_instances=task_instance_summaries[dag_run.run_id]
if dag_run.run_id in task_instance_summaries
else [],
task_instances=(
task_instance_summaries[dag_run.run_id] if dag_run.run_id in task_instance_summaries else []
),
)
for dag_run in dag_runs
]
Expand Down
3 changes: 1 addition & 2 deletions airflow/ui/openapi-gen/requests/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3401,8 +3401,7 @@ export const $GridDAGRunwithTIs = {
version_number: {
anyOf: [
{
type: "string",
format: "uuid",
type: "integer",
},
{
type: "null",
Expand Down
2 changes: 1 addition & 1 deletion airflow/ui/openapi-gen/requests/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ export type GridDAGRunwithTIs = {
run_type: DagRunType;
data_interval_start: string | null;
data_interval_end: string | null;
version_number: string | null;
version_number: number | null;
note: string | null;
task_instances: Array<GridTaskInstanceSummary>;
};
Expand Down

0 comments on commit a078cce

Please sign in to comment.