kacpermuda commented on code in PR #70760:
URL: https://github.com/apache/airflow/pull/70760#discussion_r3713310632
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -458,6 +458,25 @@ def _get_team_names_for_dag_ids(
# Ensure all requested dag_ids are in the result (with None for those
not found)
return {dag_id: self._dag_id_to_team_name.get(dag_id) for dag_id in
dag_ids}
+ def _stamp_team_names(self, dag_runs: Iterable[DagRun], session: Session)
-> None:
+ """
+ Stamp ``_team_name`` on each DagRun.
+
+ Team names are resolved via ``_get_team_names_for_dag_ids``, which
caches results in
+ ``self._dag_id_to_team_name`` for the duration of the current
scheduler loop. In
+ practice this means the first call per loop issues one batched query;
subsequent calls
+ for the same dag_ids are pure dict reads with no DB round-trip.
+ """
+ if not self._multi_team:
+ return
+ runs = list(dag_runs)
+ if not runs:
+ return
+ team_map = self._get_team_names_for_dag_ids({dr.dag_id for dr in
runs}, session)
+ for dr in runs:
Review Comment:
applied !
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2981,6 +2995,9 @@ def _schedule_dag_run(
execute=False,
)
+ # dag_run was reloaded from DB above, so _team_name set on the
original object is lost.
+ # Team name should be added before listeners are called in
notify_dagrun_state_changed()
Review Comment:
applied !
--
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]