This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new cd5ccf0abf5 Fix flakey test in DAG serialization (#44480)
cd5ccf0abf5 is described below

commit cd5ccf0abf5027cf457b36a8a2bee397dcb538b4
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Fri Nov 29 15:48:35 2024 +0000

    Fix flakey test in DAG serialization (#44480)
    
    This behaviour is very odd, and is not in anyway clear _why_ it's happening,
    but the fix is to not construct a DAG object, but to use attrs to tell us 
what
    the fields are -- which is better behaviour anyway.
    
    To reproduce the issue before this change:
    
    1. `pytest 
tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_deserialization_with_dag_context`
 -> greeen
    2. `pytest 
tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_deserialization_with_dag_context`
 -> boom
    
    (So by dag objects existing in the DB it somehow "poluted" the
    DagContextManager/TaskContextManager stack. I haven't dug into exactly how
    that might be happening.)
---
 task_sdk/src/airflow/sdk/definitions/dag.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/task_sdk/src/airflow/sdk/definitions/dag.py 
b/task_sdk/src/airflow/sdk/definitions/dag.py
index 20621ba148f..d02480c8ab1 100644
--- a/task_sdk/src/airflow/sdk/definitions/dag.py
+++ b/task_sdk/src/airflow/sdk/definitions/dag.py
@@ -991,7 +991,7 @@ class DAG:
                 "fail_stop",
                 "schedule",
             }
-            cls.__serialized_fields = frozenset(vars(DAG(dag_id="test", 
schedule=None))) - exclusion_list
+            cls.__serialized_fields = frozenset(a.name for a in 
attrs.fields(cls)) - exclusion_list
         return cls.__serialized_fields
 
     def get_edge_info(self, upstream_task_id: str, downstream_task_id: str) -> 
EdgeInfoType:

Reply via email to