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

 ##########
 File path: airflow/models/dag.py
 ##########
 @@ -591,6 +593,29 @@ def owner(self) -> str:
         """
         return ", ".join({t.owner for t in self.tasks})
 
+    def code(self):
+        if conf.getboolean('core', 'store_dag_code', fallback=False):
+            return self._get_code_from_db()
+        else:
+            return self._get_code_from_file()
+
+    def _get_code_from_file(self):
+        with open_maybe_zipped(self.fileloc, 'r') as f:
+            code = f.read()
+        return code
+
+    @provide_session
+    def _get_code_from_db(self, session=None):
+        fileloc_hash = DagCode.dag_fileloc_hash(self.fileloc)
 
 Review comment:
   Here we create cyclical imports. These 3 methods should be in the DagCode 
class. I don't see the reason why the person who calls the method cannot call 
``DagCode.get_by_fileloc (dag.fileloc)``

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