ashb commented on code in PR #50372:
URL: https://github.com/apache/airflow/pull/50372#discussion_r2083142999
##########
airflow-core/src/airflow/api_fastapi/common/deps.py:
##########
@@ -14,16 +14,22 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+
from __future__ import annotations
import os
+from typing import Annotated
+
+from fastapi import Depends
-from airflow.models import DagBag
+from airflow.models.dagbag import DagBag
from airflow.settings import DAGS_FOLDER
-def get_dag_bag() -> DagBag:
- """Instantiate the appropriate DagBag based on the ``SKIP_DAGS_PARSING``
environment variable."""
+def _get_dag_bag() -> DagBag:
if os.environ.get("SKIP_DAGS_PARSING") == "True":
return DagBag(os.devnull, include_examples=False)
return DagBag(DAGS_FOLDER, read_dags_from_db=True)
+
+
+DagBagDep = Annotated[DagBag, Depends(_get_dag_bag)]
Review Comment:
It's okay making this a dep, but given DagBag acts as a cache for DAGs, I
think we still want to have the "backing store" for this dependency be
`app.state` so that there is a single shared cached instance, rather than each
and every request creating a new dag bag when it needs it
--
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]