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


##########
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:
   `hash` method already does this:
   
   ```python 
   
       def hash(cls, dag_data):
           """Hash the data to get the dag_hash."""
           dag_data = cls._sort_serialized_dag_dict(dag_data)
           data_ = dag_data.copy()
           # Remove fileloc from the hash so changes to fileloc
           # does not affect the hash. In 3.0+, a combination of
           # bundle_path and relative fileloc more correctly determines the
           # dag file location.
           data_["dag"].pop("fileloc", None)
           data_json = json.dumps(data_, sort_keys=True).encode("utf-8")
           return md5(data_json).hexdigest()
   ```



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