dstandish commented on code in PR #53429:
URL: https://github.com/apache/airflow/pull/53429#discussion_r2219660328
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py:
##########
@@ -191,3 +195,36 @@ def get_dags(
total_entries=total_entries,
dags=list(dag_runs_by_dag_id.values()),
)
+
+
+@dags_router.get(
+ "/{dag_id}/latest_run",
+ responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
+ dependencies=[Depends(requires_access_dag(method="GET",
access_entity=DagAccessEntity.RUN))],
+)
+def get_latest_run_info(dag_id: str, session: SessionDep) ->
list[DAGRunLightResponse]:
+ """Get latest run."""
+ if dag_id == "~":
+ raise HTTPException(
+ status.HTTP_400_BAD_REQUEST,
+ "`~` was supplied as dag_id, but querying multiple dags is not
supported.",
Review Comment:
`get_dag_runs` is slow and makes a much bigger query. the problem with the
public API is it has know clue what it's trying to do, no clue why it is
serving the request, or what the client is really after. so it just gives
everything. so you load the full object along with referenced info like dag
run notes and dag versions etc and it's just very bloated.
so, it's doing stuff you don't need, and as a result it's slow and
inefficient.
performance is not the only issue here. you also have coupling. when many
things are using the same endpoint, you have to meet all the needs of all the
things that are using that endpoint. which generally means you have to do
_more_ in that endpoint. which means it's going to be bloated and slower than
necessary. also, more of a pain to change. or, you add more and more
configuration to make it return different kinds of info based on different
parameters. this just gets more and more complicated and i do not think it
ends up simpler to maintain than distinct endpoints.
i think the suggestion to combine `get_latest_run_info` and `get_latest_run`
is much more promising than the suggestion to continue to use the public API
--
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]