airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (AIRFLOW-2836) Minor improvement of contrib.sensors.FileSensor
Date Fri, 03 Aug 2018 13:48:00 GMT


ASF GitHub Bot commented on AIRFLOW-2836:

Fokko closed pull request #3674: [AIRFLOW-2836] Minor improvement of contrib.sensors.FileSensor

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/contrib/sensors/ b/airflow/contrib/sensors/
index 3f7bb24e08..3e49abdfb5 100644
--- a/airflow/contrib/sensors/
+++ b/airflow/contrib/sensors/
@@ -46,7 +46,7 @@ class FileSensor(BaseSensorOperator):
     def __init__(self,
-                 fs_conn_id='fs_default2',
+                 fs_conn_id='fs_default',
         super(FileSensor, self).__init__(*args, **kwargs)
@@ -56,7 +56,7 @@ def __init__(self,
     def poke(self, context):
         hook = FSHook(self.fs_conn_id)
         basepath = hook.get_path()
-        full_path = "/".join([basepath, self.filepath])
+        full_path = os.path.join(basepath, self.filepath)'Poking for file {full_path}'.format(**locals()))
             if stat.S_ISDIR(os.stat(full_path).st_mode):
diff --git a/tests/contrib/sensors/ b/tests/contrib/sensors/
index d78400e317..0bb0007c60 100644
--- a/tests/contrib/sensors/
+++ b/tests/contrib/sensors/
@@ -125,6 +125,18 @@ def test_file_in_dir(self):
+    def test_default_fs_conn_id(self):
+        with tempfile.NamedTemporaryFile() as tmp:
+            task = FileSensor(
+                task_id="test",
+      [1:],
+                dag=self.dag,
+                timeout=0,
+            )
+            task._hook = self.hook
+  , end_date=DEFAULT_DATE,
+                     ignore_ti_state=True)
 if __name__ == '__main__':


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

> Minor improvement of contrib.sensors.FileSensor
> -----------------------------------------------
>                 Key: AIRFLOW-2836
>                 URL:
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: contrib
>            Reporter: Xiaodong DENG
>            Assignee: Xiaodong DENG
>            Priority: Minor
> h4. *Background*
> The default *fs_conn_id* in contrib.sensors.FileSensor is '_*fs_default2*_'. However,
when we initiate the database (,
there isn't such an entry. It doesn't exist anywhere else.
> h4. *Issue*
> The purpose of _contrib.sensors.FileSensor_ is mainly for checking local file system
(of course can also be used for NAS). Then the path ("/") from default connection 'fs_default'
would suffice.
> However, given the default value for *fs_conn_id* in contrib.sensors.FileSensor is
"fs_default2" (a value doesn't exist), it will make the situation much more complex. 
> When users intend to check local file system only, they should be able to leave *fs_conn_id* default
directly, instead of going setting up another connection separately.
> h4. Proposal
> Change default value for *fs_conn_id* in contrib.sensors.FileSensor from "fs_default2"
to "fs_default" (actually in the related test, the *fs_conn_id* are all specified to be "fs_default").

This message was sent by Atlassian JIRA

View raw message