You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/28 07:48:04 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #16860: Support DAGS folder being in different location on scheduler and runners

uranusjr commented on a change in pull request #16860:
URL: https://github.com/apache/airflow/pull/16860#discussion_r678058497



##########
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:
       Why not just return the Path object? This is new so there's no compatibility considerations, and a Path can be used in almost all places where str is accepted these days (`os.PathLike`).




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org