ashb commented on a change in pull request #5743: [AIRFLOW-5088][AIP-24] 
Persisting serialized DAG in DB for webserver scalability
URL: https://github.com/apache/airflow/pull/5743#discussion_r312812554
 
 

 ##########
 File path: airflow/models/dag.py
 ##########
 @@ -1509,8 +1518,19 @@ def get_last_dagrun(self, session=None, 
include_externally_triggered=False):
     def safe_dag_id(self):
         return self.dag_id.replace('.', '__dot__')
 
-    def get_dag(self):
-        return DagBag(dag_folder=self.fileloc).get_dag(self.dag_id)
+    def get_dag(self, dagcached_enabled=False):
+        """Creates a dagbag to load and return a DAG.
+
+        Calling it from UI should set dagcached_enabled = DAGCACHED_ENABLED.
+        There may be a delay for scheduler to write serialized DAG into 
database,
+        loads from file in this case.
+        FIXME: removes it when webserver does not access to DAG folder in 
future.
+        """
+        dag = DagBag(
+            dag_folder=self.fileloc, 
dagcached_enabled=dagcached_enabled).get_dag(self.dag_id)
+        if dagcached_enabled and dag is None:
 
 Review comment:
   Something about this method feels... off to me: it's a bit hard to follow 
the logic, and the use of recursion to re-load the DagBag without the cache 
enabled makes it harder to follow the logic.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to