pierrejeambrun commented on code in PR #62160:
URL: https://github.com/apache/airflow/pull/62160#discussion_r2841984262
##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_run.py:
##########
@@ -87,6 +87,54 @@ class DAGRunResponse(BaseModel):
partition_key: str | None
+class DAGRunBaseResponse(BaseModel):
+ dag_run_id: str = Field(validation_alias="run_id")
+ dag_id: str
+ logical_date: datetime | None
+ queued_at: datetime | None
+ start_date: datetime | None
+ end_date: datetime | None
+ duration: float | None
+ data_interval_start: datetime | None
+ data_interval_end: datetime | None
+ run_after: datetime
+ last_scheduling_decision: datetime | None
+ run_type: DagRunType
+ state: DagRunState
+ triggered_by: DagRunTriggeredByType | None
+ triggering_user_name: str | None
+ conf: dict | None
+ note: str | None
+ bundle_version: str | None
+ dag_display_name: str = Field(validation_alias=AliasPath("dag_model",
"dag_display_name"))
+ partition_key: str | None
+
+
+class DAGRunListResponse(DAGRunBaseResponse):
+ created_dag_version_obj: DagVersionResponse | None = Field(
+ default=None,
+ validation_alias="created_dag_version",
+ exclude=True,
+ )
+
+ @computed_field(return_type=list[DagVersionResponse])
+ def dag_versions(self) -> list[DagVersionResponse]:
+ dv = self.created_dag_version_obj
+ if not dv:
+ return []
+
+ # Non-versioned DAGs must not expose versions
+ if dv.bundle_name is None:
+ return []
+
+ return [dv]
+
Review Comment:
This is more or less not consistent with what we have today, can you explain
why you are not returning the `dag_versions` object from the model but the
'created_dag_version" ?
##########
airflow-core/src/airflow/api_fastapi/common/db/dag_runs.py:
##########
@@ -52,3 +52,14 @@ def eager_load_dag_run_for_validation() ->
tuple[LoaderOption, ...]:
.joinedload(DagVersion.bundle),
joinedload(DagRun.dag_run_note),
)
+
+
+def eager_load_dag_run_for_list() -> tuple[LoaderOption, ...]:
+ return (
+ joinedload(DagRun.dag_model),
+ joinedload(DagRun.dag_run_note),
+ joinedload(DagRun.created_dag_version)
+ .joinedload(DagVersion.bundle),
+ joinedload(DagRun.created_dag_version)
+ .joinedload(DagVersion.dag_model),
Review Comment:
Can you explain the motivation here?
We're not eager loading TI and TIH for `dag_versions` is that it?
Those will be lazy loaded at serialization time?
--
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]