I am designing a custom sensor, MySensor, in Airflow 2 which i am creating by overriding the BaseSensorOperator. I have a parameter called file
which is passed to my constructor as a template field
template_fields = ("file",)
I have an Airflow variable named file which holds the value for the parameter file.Then i instantiate a task in my DAG as follows.
my_task = MySensor(task_id="my_task", file = "{{var.value.file}}")
This works correctly as it is a template field and the value stored in the Airflow variable will be used. But the problem arises when I pass this argument as a string, that is without a Jinja template.
my_task = MySensor(task_id="my_task", file = "/my_test_file.jar")
This gives me an error AttributeError: 'MySensor' object has no attribute 'file'
.
Is there something I am missing here? How can I pass non templated arguments to template field in Airflow 2