Skip to content

Commit

Permalink
fix(sensors): move trigger initialization from __init___ to execute (#…
Browse files Browse the repository at this point in the history
…33926)

in #33403, we move trigger initialization to __init__
which causes a failure for one uses template variable
  • Loading branch information
Lee-W authored Aug 30, 2023
1 parent 1dc6ba0 commit eaa6126
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions airflow/sensors/date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ class DateTimeSensorAsync(DateTimeSensor):

def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.trigger = DateTimeTrigger(moment=timezone.parse(self.target_time))

def execute(self, context: Context):
trigger = DateTimeTrigger(moment=timezone.parse(self.target_time))
self.defer(
trigger=self.trigger,
trigger=trigger,
method_name="execute_complete",
)

Expand Down
4 changes: 2 additions & 2 deletions airflow/sensors/time_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def __init__(self, *, target_time, **kwargs):
)

self.target_datetime = timezone.convert_to_utc(aware_time)
self.trigger = DateTimeTrigger(moment=self.target_datetime)

def execute(self, context: Context):
trigger = DateTimeTrigger(moment=self.target_datetime)
self.defer(
trigger=self.trigger,
trigger=trigger,
method_name="execute_complete",
)

Expand Down

0 comments on commit eaa6126

Please sign in to comment.