kaxil commented on a change in pull request #7217: [AIRFLOW-5946] Store source 
code in db
URL: https://github.com/apache/airflow/pull/7217#discussion_r383234120
 
 

 ##########
 File path: airflow/models/serialized_dag.py
 ##########
 @@ -72,23 +72,10 @@ class SerializedDagModel(Base):
     def __init__(self, dag: DAG):
         self.dag_id = dag.dag_id
         self.fileloc = dag.full_filepath
-        self.fileloc_hash = self.dag_fileloc_hash(self.fileloc)
+        self.fileloc_hash = DagCodeModel.dag_fileloc_hash(self.fileloc)
         self.data = SerializedDAG.to_dict(dag)
         self.last_updated = timezone.utcnow()
 
-    @staticmethod
-    def dag_fileloc_hash(full_filepath: str) -> int:
-        """"Hashing file location for indexing.
-
-        :param full_filepath: full filepath of DAG file
-        :return: hashed full_filepath
-        """
-        # hashing is needed because the length of fileloc is 2000 as an 
Airflow convention,
-        # which is over the limit of indexing. If we can reduce the length of 
fileloc, then
-        # hashing is not needed.
-        return int.from_bytes(
-            hashlib.sha1(full_filepath.encode('utf-8')).digest()[-2:], 
byteorder='big', signed=False)
-
     @classmethod
     @provide_session
     def write_dag(cls, dag: DAG, min_update_interval: Optional[int] = None, 
session=None):
 
 Review comment:
   It is here: 
https://github.com/apache/airflow/pull/7217/files#diff-40e3d1f11ed05554009ad08fa603a1e8L111

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to