Skip to content

Commit

Permalink
Fix flakey test in DAG serialization (apache#44480)
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
ashb authored Nov 29, 2024
1 parent c4d44e7 commit cd5ccf0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion task_sdk/src/airflow/sdk/definitions/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ def get_serialized_fields(cls):
"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:
Expand Down

0 comments on commit cd5ccf0

Please sign in to comment.