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

 ##########
 File path: airflow/models/dag.py
 ##########
 @@ -1753,6 +1756,44 @@ def get_last_dagrun(self, session=None, 
include_externally_triggered=False):
     def safe_dag_id(self):
         return self.dag_id.replace('.', '__dot__')
 
+    @property
+    def code(self):
+        if conf.getboolean('core', 'store_code', fallback=False):
+            return self._get_code_from_db(self.fileloc)
+        else:
+            return self._get_code_from_file(self.fileloc)
+
+    def _get_code_from_file(self, fileloc):
+        with self._open_maybe_zipped(fileloc, 'r') as f:
+            code = f.read()
+        return code
+
+    @classmethod
+    def _open_maybe_zipped(cls, f, mode='r'):
 
 Review comment:
   I definitely agree.

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