ashb commented on a change in pull request #16860:
URL: https://github.com/apache/airflow/pull/16860#discussion_r678368865
##########
File path: airflow/models/dag.py
##########
@@ -734,15 +760,25 @@ def task_group(self) -> "TaskGroup":
@property
def filepath(self) -> str:
- """File location of where the dag object is instantiated"""
- fn = self.full_filepath.replace(settings.DAGS_FOLDER + '/', '')
- fn = fn.replace(os.path.dirname(__file__) + '/', '')
- return fn
+ """:meta private:"""
+ warnings.warn(
+ "filepath is deprecated, use relative_fileloc instead",
DeprecationWarning, stacklevel=2
+ )
+ return self.relative_fileloc
+
+ @property
+ def relative_fileloc(self) -> str:
+ """File location of the importable dag 'file' relative to the
configured DAGs folder."""
+ try:
+ return
str(pathlib.Path(self.fileloc).relative_to(settings.DAGS_FOLDER))
Review comment:
Fair point -- this can return a path object, and the compat layers that
call it can force a string return.
--
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]