jason810496 commented on code in PR #52177:
URL: https://github.com/apache/airflow/pull/52177#discussion_r2173789701


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py:
##########
@@ -122,9 +121,20 @@ def clear_dag_run(
                 "message": f"DAG with dag_id: '{dag_id}' has import errors and 
cannot be triggered",
             },
         )
+    from airflow.jobs.scheduler_job_runner import SchedulerDagBag
+
+    dag_run = session.scalar(select(DagRun).where(DagRun.dag_id == dag_id, 
DagRun.run_id == run_id))
+    dag_bag = SchedulerDagBag()

Review Comment:
   Then we can get the same `SchedulerDagBag` instance via `SchedulerDagBagDep` 
Depends.



##########
airflow-core/src/airflow/api_fastapi/app.py:
##########
@@ -83,8 +83,10 @@ def create_app(apps: str = "all") -> FastAPI:
     dag_bag = create_dag_bag()
 
     if "execution" in apps_list or "all" in apps_list:
+        from airflow.jobs.scheduler_job_runner import SchedulerDagBag
+
         task_exec_api_app = create_task_execution_api_app()
-        task_exec_api_app.state.dag_bag = dag_bag
+        task_exec_api_app.state.dag_bag = SchedulerDagBag()
         init_error_handlers(task_exec_api_app)

Review Comment:
   Just to make double check, so after this PR.
   
   All the `dag_bag` in core-api usage will change from `create_dag_bag()` ( 
which return `DagBag(DAGS_FOLDER, read_dags_from_db=True)` ) to 
`SchedulerDagBag()` right ?
   
   Since the PR summary only mentioning execution API
   > Use SchedulerDagBag instead of DagBag for execution API.



##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -75,6 +75,9 @@
 
     from airflow.sdk.types import Operator
 
+from airflow.jobs.scheduler_job_runner import SchedulerDagBag
+
+SchedulerDagBagDep = Annotated[SchedulerDagBag, Depends(dag_bag_from_app)]

Review Comment:
   If then, should we move `SchedulerDagBagDep = Annotated[SchedulerDagBag, 
Depends(dag_bag_from_app)]` to  `airflow.api_fastapi.common.dagbag`?
   Or mauby replace the `DagBagDep` FastAPI `Depends` with `SchedulerDagBag`?



##########
airflow-core/src/airflow/api_fastapi/app.py:
##########
@@ -83,8 +83,10 @@ def create_app(apps: str = "all") -> FastAPI:
     dag_bag = create_dag_bag()

Review Comment:
   ```suggestion
   ```



-- 
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]

Reply via email to