I am new to Python and airflow. Trying to implement a sensor as below, and the error says "AttributeError: 'mySensor' object has no attribute 'l'" I had a look at other attribute error questions, but I have no idea where the 'l' in my error comes from. Could someone help shed some light on this? Below is the whole class for mySensor. Many thanks.
class mySensor(SFTPSensor):
"""
Subclass of SFTPSensor to override the poke() method
"""
template_fields = "previous_month"
@apply_defaults
def __init__(self,
last_day_previous_month,
*args,
**kwargs):
self.previous_month = previous_month
super(mySensor, self).__init__(*args, **kwargs)
def poke(self, context):
remote_path = self.path+"file_to_check"+self.previous_month
file_count = len(self.hook.list_directory(remote_path))
if file_count == 0:
return False
else:
logging.info("Found %d files", file_count)
return True
and where I used the Sensor
sensor_task = mySensor(
previous_month=_previous_month_template,
task_id="check-remote-files",
dag=dag,
sftp_conn_id=my_conn_id,
path="/my/path/"
)
template_fields = "previous_month"totemplate_fields = ["previous_month"]? It is expected to be a list or tuple. Also I don't seelast_day_previous_monthargument being passed to the sensor but it is an expected argument in__init__function in your sensor