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_r391774159
##########
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:
In this case it seems to me that better would be enemy of good enough :)
There is no good place in current architecture. I agree that this solution
is better than previous one. And it seems to me that DagBag will definitely
gain functionality and this once proven to work will not be changed anymore.
----------------------------------------------------------------
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