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

potiuk 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 adb9466bd7 Fix the order of tasks during serialization (#42219)
adb9466bd7 is described below

commit adb9466bd7ce1c92e51f11a90d39fd557c99dc5b
Author: Alexander Millin <[email protected]>
AuthorDate: Wed Oct 2 03:44:04 2024 +0300

    Fix the order of tasks during serialization (#42219)
    
    SerializedDagModel().dag_hash may change if the order of tasks is not fixed
---
 airflow/serialization/serialized_objects.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/airflow/serialization/serialized_objects.py 
b/airflow/serialization/serialized_objects.py
index a4801b767a..08944391b8 100644
--- a/airflow/serialization/serialized_objects.py
+++ b/airflow/serialization/serialized_objects.py
@@ -1604,7 +1604,9 @@ class SerializedDAG(DAG, BaseSerialization):
         try:
             serialized_dag = cls.serialize_to_json(dag, cls._decorated_fields)
             serialized_dag["_processor_dags_folder"] = DAGS_FOLDER
-            serialized_dag["tasks"] = [cls.serialize(task) for _, task in 
dag.task_dict.items()]
+            serialized_dag["tasks"] = [
+                cls.serialize(dag.task_dict[task_id]) for task_id in 
sorted(dag.task_dict)
+            ]
 
             dag_deps = [
                 dep

Reply via email to