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

(cherry picked from commit eaa6126)
  • Loading branch information
Lee-W authored and ephraimbuddy committed Sep 1, 2023
1 parent 8754b50 commit d088626
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 @@ -87,11 +87,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 @@ -68,11 +68,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 d088626

Please sign in to comment.