You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/09/12 07:58:56 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #26287: Respect max_active_runs setting when queuing dataset-driven dag runs

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


##########
airflow/jobs/scheduler_job.py:
##########
@@ -1092,6 +1092,10 @@ def _create_dag_runs_dataset_triggered(
                 tuple_in_condition((DagRun.dag_id, DagRun.execution_date), exec_dates.items())
             )
         )
+        active_runs_of_dags = defaultdict(
+            int,
+            DagRun.active_runs_of_dags(dag_ids=(dm.dag_id for dm in dag_models), session=session),
+        )

Review Comment:
   Since this is really only used once, and non-zero is only possible if the key exists, the additional `defaultdict` conversion is not really needed?
   
   ```python
   active_runs_of_dags = DagRun.active_runs_of_dags(dag_ids=(dm.dag_id for dm in dag_models), session=session)
   
   ...
   
   with contextlib.suppress(KeyError):
       active_runs = active_runs_of_dags[dag_model.dag_id]
       if active_runs >= dag_model.max_active_runs:
           ...
   ```



-- 
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-unsubscribe@airflow.apache.org

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