mik-laj commented on a change in pull request #7806: Decouple DAG from DagBag 
and DAG from SerializedDagModel - remove cyclic imports
URL: https://github.com/apache/airflow/pull/7806#discussion_r396244696
 
 

 ##########
 File path: airflow/www/utils.py
 ##########
 @@ -457,3 +424,18 @@ def is_utcdatetime(self, col_name):
         return False
 
     filter_converter_class = UtcAwareFilterConverter
+
+
+def get_dag(dag, store_serialized_dags=False):
+    """Creates a dagbag to load and return a DAG.
+
+    Calling it from UI should set store_serialized_dags = 
STORE_SERIALIZED_DAGS.
+    There may be a delay for scheduler to write serialized DAG into database,
+    loads from file in this case.
+    FIXME: remove it when webserver does not access to DAG folder in future.
+    """
+    dag = DagBag(
+        dag_folder=dag.fileloc, 
store_serialized_dags=store_serialized_dags).get_dag(dag.dag_id)
+    if store_serialized_dags and dag is None:
+        dag = DagBag(dag_folder=dag.fileloc, 
store_serialized_dags=False).get_dag(dag.dag_id)
 
 Review comment:
   I deleted the recursion to make this code more readable.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to