dstandish commented on code in PR #49097:
URL: https://github.com/apache/airflow/pull/49097#discussion_r2042226519
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -102,6 +102,55 @@
""":meta private:"""
+class SchedulerDagBag:
+ """
+ Internal class for retrieving and caching dags in the scheduler.
+
+ :meta private:
+ """
+
+ def __init__(self):
+ self._dags: dict[str, DAG] = {} # dag_version_id to dag
+
+ def _get_dag(self, version_id: str, session: Session) -> DAG | None:
+ if dag := self._dags.get(version_id):
+ return dag
+ dag_version = session.get(DagVersion, version_id)
+ if not dag_version:
+ return None
+ serdag = dag_version.serialized_dag
Review Comment:
i tend to prefer to be lazy because then you get surprise joins in queries
i would not add it in the relationship itself. but we could do it on a
query by query basis. e.g. here, we could add an option for eager loading.
--
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]