Lee-W commented on code in PR #36840:
URL: https://github.com/apache/airflow/pull/36840#discussion_r1456733164
##########
airflow/sensors/filesystem.py:
##########
@@ -53,19 +58,31 @@ class FileSensor(BaseSensorOperator):
template_fields: Sequence[str] = ("filepath",)
ui_color = "#91818a"
- def __init__(self, *, filepath, fs_conn_id="fs_default", recursive=False,
**kwargs):
+ def __init__(
+ self,
+ *,
+ filepath,
+ fs_conn_id="fs_default",
+ recursive=False,
+ deferrable: bool = conf.getboolean("operators", "default_deferrable",
fallback=False),
+ **kwargs,
+ ):
super().__init__(**kwargs)
self.filepath = filepath
self.fs_conn_id = fs_conn_id
self.recursive = recursive
+ self.deferrable = deferrable
- def poke(self, context: Context):
+ @property
Review Comment:
Should we make it a `cached_property`?
##########
airflow/sensors/filesystem.py:
##########
@@ -53,19 +58,31 @@ class FileSensor(BaseSensorOperator):
template_fields: Sequence[str] = ("filepath",)
ui_color = "#91818a"
- def __init__(self, *, filepath, fs_conn_id="fs_default", recursive=False,
**kwargs):
+ def __init__(
+ self,
+ *,
+ filepath,
+ fs_conn_id="fs_default",
+ recursive=False,
+ deferrable: bool = conf.getboolean("operators", "default_deferrable",
fallback=False),
+ **kwargs,
+ ):
super().__init__(**kwargs)
self.filepath = filepath
self.fs_conn_id = fs_conn_id
self.recursive = recursive
+ self.deferrable = deferrable
- def poke(self, context: Context):
+ @property
+ def path(self):
hook = FSHook(self.fs_conn_id)
basepath = hook.get_path()
full_path = os.path.join(basepath, self.filepath)
self.log.info("Poking for file %s", full_path)
Review Comment:
Should we move this log to `def poke` instead?
##########
airflow/sensors/filesystem.py:
##########
@@ -53,19 +58,31 @@ class FileSensor(BaseSensorOperator):
template_fields: Sequence[str] = ("filepath",)
ui_color = "#91818a"
- def __init__(self, *, filepath, fs_conn_id="fs_default", recursive=False,
**kwargs):
+ def __init__(
+ self,
+ *,
+ filepath,
+ fs_conn_id="fs_default",
+ recursive=False,
+ deferrable: bool = conf.getboolean("operators", "default_deferrable",
fallback=False),
+ **kwargs,
+ ):
super().__init__(**kwargs)
self.filepath = filepath
self.fs_conn_id = fs_conn_id
self.recursive = recursive
+ self.deferrable = deferrable
- def poke(self, context: Context):
+ @property
+ def path(self):
hook = FSHook(self.fs_conn_id)
basepath = hook.get_path()
full_path = os.path.join(basepath, self.filepath)
self.log.info("Poking for file %s", full_path)
+ return full_path
- for path in glob(full_path, recursive=self.recursive):
+ def poke(self, context: Context):
Review Comment:
```suggestion
def poke(self, context: Context) -> bool:
```
--
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]