wolvery commented on code in PR #56476:
URL: https://github.com/apache/airflow/pull/56476#discussion_r2415100796


##########
airflow-core/src/airflow/models/serialized_dag.py:
##########
@@ -410,7 +429,12 @@ def write_dag(
                 return False
 
         log.debug("Checking if DAG (%s) changed", dag.dag_id)
+
+        serialized_json = cls.serialize_dag(dag)
         new_serialized_dag = cls(dag)
+        new_serialized_dag._data = serialized_json
+        new_serialized_dag.dag_hash = 
hashlib.sha1(serialized_json.encode()).hexdigest()

Review Comment:
   Hey, I've been checking the serialized_dags, and I've seen a lot of versions 
to the same dag and it seems that the JSON persisted in that table is not 
sorted. The keys/values are matching, only the order of the internal keys are 
not matching inside of the dag json, here it is an example:
   ```
   --- version_1
   +++ version_2
   @@ -1,13 +1,13 @@
   -"dag_id": "test",
   -"max_consecutive_failed_dag_runs": 7,
   -"timetable": { ... },
   -"relative_fileloc": "revision_dags/test.py",
   -"task_group": { ... },
   -"fileloc": "/opt/airflow/dags/revision_dags/test.py",
   -"timezone": "UTC",
   -"default_args": { ... },
   -"description": "DAG for [domain='test', 
data_product='polaroid_input_features', pipeline='main']",
   -"max_active_runs": 1,
   -"tags": [ ... ],
   -"start_date": 1640995200.0
   +"max_consecutive_failed_dag_runs": 7,
   +"task_group": { ... },
   +"timezone": "UTC",
   +"max_active_runs": 1,
   +"fileloc": "/opt/airflow/dags/revision_dags/test.py",
   +"timetable": { ... },
   +"start_date": 1640995200.0,
   +"description": "DAG for [domain='test', 
data_product='polaroid_input_features', pipeline='main']",
   +"default_args": { ... },
   +"tags": [ ... ],
   +"relative_fileloc": "revision_dags/test.py",
   +"dag_id": "test"
   ```
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to