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


##########
airflow-core/src/airflow/models/dag.py:
##########
@@ -896,17 +910,28 @@ def calculate_dagrun_date_fields(
         )
 
     @staticmethod
-    @cached(_team_name_cache, key=lambda dag_id, **_: dag_id, 
lock=_team_name_cache_lock)
-    @provide_session
-    def get_team_name(dag_id: str, *, session: Session = NEW_SESSION) -> str | 
None:
-        """Return the team name associated to a Dag or None if it is not owned 
by a specific team."""
-        stmt = (
+    def _build_team_name_query(dag_id: str) -> Select[tuple[str]]:
+        return (
             select(Team.name)
             .join(DagBundleModel.teams)
             .join(DagModel, DagModel.bundle_name == DagBundleModel.name)
             .where(DagModel.dag_id == dag_id)
         )
-        return session.scalar(stmt)
+
+    @staticmethod
+    def get_team_name(dag_id: str, *, session: Session | None = None) -> str | 
None:

Review Comment:
   Nit: the comment in `DagModel.team_name` (line 486) still says 
`get_team_name` is `@provide_session`. Could we update it?
   
   ```python
   # ``get_team_name`` opens a scoped session when none is passed, and that is 
the *same*
   # scoped session the caller holds, so closing it on exit would detach
   # every object still in use.
   ```



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