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 2021/04/11 14:45:53 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #15302: Emit error on duplicated DAG ID

uranusjr commented on a change in pull request #15302:
URL: https://github.com/apache/airflow/pull/15302#discussion_r611199277



##########
File path: airflow/models/dagbag.py
##########
@@ -195,6 +200,11 @@ def get_dag(self, dag_id, session: Session = None):
                     session=session,
                 )
                 if sd_last_updated_datetime and sd_last_updated_datetime > self.dags_last_fetched[dag_id]:
+                    self.dags = {  # Remove associated dags to re-add them.
+                        key: dag
+                        for key, dag in self.dags.items()
+                        if dag_id not in (key, dag.parent_dag.dag_id)

Review comment:
       Before any suggests `key != dag_id and dag.parent_dag.dag_id != dag_id`, which is both more logically easier to understand and probably more performant (shortcircuiting): pylint forces me to write this, and I can’t figure out a way to turn it off.




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

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