uranusjr commented on code in PR #32122:
URL: https://github.com/apache/airflow/pull/32122#discussion_r1264984045


##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -277,9 +288,51 @@ def __get_concurrency_maps(self, states: 
Iterable[TaskInstanceState], session: S
             .where(TI.state.in_(states))
             .group_by(TI.task_id, TI.run_id, TI.dag_id)
         )
-        return ConcurrencyMap.from_concurrency_map(
-            {(dag_id, run_id, task_id): count for task_id, run_id, dag_id, 
count in ti_concurrency_query}
+        ti_concurrency = {
+            (dag_id, run_id, task_id): count for task_id, run_id, dag_id, 
count in ti_concurrency_query
+        }
+
+        tg_concurrency_query: Iterator[tuple[str, str, str, int]] = 
session.execute(
+            select(TI.task_id, TI.run_id, TI.dag_id, TI.map_index)
+            .where(
+                TI.map_index >= 0,
+                TI.state.in_(
+                    (
+                        TaskInstanceState.SCHEDULED,
+                        TaskInstanceState.QUEUED,
+                        TaskInstanceState.RUNNING,
+                        TaskInstanceState.UP_FOR_RESCHEDULE,
+                        TaskInstanceState.UP_FOR_RETRY,
+                    )

Review Comment:
   None means the task instance has not been touched by the scheduler at all, 
which is impossible in this context. So I would suggest using 
`TaskInstance.state.in_(s for s in State.unfinished if s is not None)`



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to