I have made a custom sensor in Airflow which inherits BashSensor
.
Sensor :
class MySensor(BashSensor):
def __init__(self, time, **kwargs): # {{ ts }} is passed as time in the DAG
self.time = time
cmd = f"java some-other-stuff {self.time}" # rendered/correct value for self.time
super().__init__(**kwargs, bash_command=cmd)
def poke(self, context):
status = super().poke() # returns True or False
if status:
print(self.time) # {{ ts }} is printed instead of rendered value
else:
print("trying again")
return status
When I look at the rendered tab for the operator task in DAG I see bash_command
has the correct rendered value ({{ ts }}
is passed as time
).
The problem is whenever poke is called and True
is returned, I see {{ ts }}
in the print statement instead of the rendered value.
I expect self.time
to have the rendered value (some timestamp) not {{ ts }}
when I print it in poke
function.