jason810496 commented on code in PR #53975:
URL: https://github.com/apache/airflow/pull/53975#discussion_r2245369021
##########
airflow-core/src/airflow/api_fastapi/common/dagbag.py:
##########
@@ -38,4 +39,28 @@ def dag_bag_from_app(request: Request) -> SchedulerDagBag:
return request.app.state.dag_bag
-DagBagDep = Annotated[SchedulerDagBag, Depends(dag_bag_from_app)]
+def get_latest_version_of_dag(dag_bag, dag_id: str, session: Session):
Review Comment:
```suggestion
def get_latest_version_of_dag(dag_bag: DBDagBag, dag_id: str, session:
Session) -> DAG:
```
##########
airflow-core/src/airflow/api_fastapi/common/dagbag.py:
##########
@@ -38,4 +39,28 @@ def dag_bag_from_app(request: Request) -> SchedulerDagBag:
return request.app.state.dag_bag
-DagBagDep = Annotated[SchedulerDagBag, Depends(dag_bag_from_app)]
+def get_latest_version_of_dag(dag_bag, dag_id: str, session: Session):
+ dag = dag_bag.get_latest_version_of_dag(dag_id, session=session)
+ if not dag:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"The Dag with ID:
`{dag_id}` was not found")
+ return dag
+
+
+def get_dag_for_run(dag_bag, dag_run, session: Session):
+ dag = dag_bag.get_dag_for_run(dag_run, session=session)
+ if not dag:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"The Dag with ID:
`{dag_run.dag_id}` was not found")
+ return dag
+
+
+def get_dag_for_run_or_latest_version(dag_bag, dag_run: Any | None, dag_id:
str | None, session: Session):
Review Comment:
```suggestion
def get_dag_for_run_or_latest_version(dag_bag: DBDagBag, dag_run: Any |
None, dag_id: str | None, session: Session) -> DAG:
```
##########
airflow-core/src/airflow/api_fastapi/common/dagbag.py:
##########
@@ -38,4 +39,28 @@ def dag_bag_from_app(request: Request) -> SchedulerDagBag:
return request.app.state.dag_bag
-DagBagDep = Annotated[SchedulerDagBag, Depends(dag_bag_from_app)]
+def get_latest_version_of_dag(dag_bag, dag_id: str, session: Session):
+ dag = dag_bag.get_latest_version_of_dag(dag_id, session=session)
+ if not dag:
+ raise HTTPException(status.HTTP_404_NOT_FOUND, f"The Dag with ID:
`{dag_id}` was not found")
+ return dag
+
+
+def get_dag_for_run(dag_bag, dag_run, session: Session):
Review Comment:
```suggestion
def get_dag_for_run(dag_bag: DBDagBag, dag_run, session: Session) -> DAG:
```
--
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]