potiuk commented on a change in pull request #6601: [AIRFLOW-6010] Remove 
cyclic imports and pylint disables
URL: https://github.com/apache/airflow/pull/6601#discussion_r350397760
 
 

 ##########
 File path: airflow/models/dag.py
 ##########
 @@ -1702,12 +1708,26 @@ def deactivate_deleted_dags(cls, alive_dag_filelocs: 
List[str], session=None):
             raise
 
 
-# Stringified DAGs and operators contain exactly these fields.
+class DagContext:
+
+    _context_managed_dag: Optional[DAG] = None
+    _previous_context_managed_dags: List[DAG] = []
 
-# pylint: disable=protected-access
-DAG._serialized_fields = frozenset(vars(DAG(dag_id='test')).keys()) - {
-    'parent_dag', '_old_context_manager_dags', 'safe_dag_id', 'last_loaded',
-    '_full_filepath', 'user_defined_filters', 'user_defined_macros',
-    '_schedule_interval', 'partial', '_old_context_manager_dags',
-    '_pickle_id', '_log', 'is_subdag', 'task_dict'
-}
+    @classmethod
+    def push_context_managed_dag(cls, dag: DAG):
+        if cls._context_managed_dag:
+            cls._previous_context_managed_dags.append(cls._context_managed_dag)
+        cls._context_managed_dag = dag
+
+    @classmethod
+    def pop_context_managed_dag(cls) -> Optional[DAG]:
+        old_dag = cls._context_managed_dag
+        if len(cls._previous_context_managed_dags):
 
 Review comment:
   I don't :). Fixed. 

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