airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joy...@apache.org
Subject [1/2] incubator-airflow git commit: [AIRFLOW-2175] Check that filepath is not None
Date Tue, 06 Mar 2018 21:02:08 GMT
Repository: incubator-airflow
Updated Branches:
  refs/heads/master 9d5cc6ef5 -> d2d2c2557


[AIRFLOW-2175] Check that filepath is not None

This handles the case where the fileloc no longer exists in the database


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/a0ba5b90
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/a0ba5b90
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/a0ba5b90

Branch: refs/heads/master
Commit: a0ba5b90b30616f50ae4cce5bb72b25f333c0161
Parents: 9d5cc6e
Author: Sam Schlegel <git@lutin.us>
Authored: Tue Mar 6 11:41:18 2018 -0800
Committer: Sam Schlegel <git@lutin.us>
Committed: Tue Mar 6 11:48:59 2018 -0800

----------------------------------------------------------------------
 airflow/models.py | 4 +++-
 tests/models.py   | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/a0ba5b90/airflow/models.py
----------------------------------------------------------------------
diff --git a/airflow/models.py b/airflow/models.py
index 98e9fcd..276fdc4 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -252,8 +252,10 @@ class DagBag(BaseDagBag, LoggingMixin):
         """
         found_dags = []
 
+        # if the source file no longer exists in the DB or in the filesystem,
+        # return an empty list
         # todo: raise exception?
-        if not os.path.isfile(filepath):
+        if filepath is None or not os.path.isfile(filepath):
             return found_dags
 
         try:

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/a0ba5b90/tests/models.py
----------------------------------------------------------------------
diff --git a/tests/models.py b/tests/models.py
index c89296e..c8ee037 100644
--- a/tests/models.py
+++ b/tests/models.py
@@ -857,6 +857,14 @@ class DagBagTest(unittest.TestCase):
             self.assertTrue(
                 dag.fileloc.endswith('airflow/example_dags/' + path))
 
+    def test_process_file_with_none(self):
+        """
+        test that process_file can handle Nones
+        """
+        dagbag = models.DagBag(include_examples=True)
+
+        self.assertEqual([], dagbag.process_file(None))
+
 
 class TaskInstanceTest(unittest.TestCase):
 


Mime
View raw message