hussein-awala commented on PR #33403:
URL: https://github.com/apache/airflow/pull/33403#issuecomment-1681294660
Since it's a problem in the initialization of the trigger, and it is not a
runtime issue, what about raising an exception in parsing time, to give the
user a fast feedback about the wrong parameters, for example:
```diff
diff --git a/airflow/sensors/date_time.py b/airflow/sensors/date_time.py
index 1425028870..a036d09e01 100644
--- a/airflow/sensors/date_time.py
+++ b/airflow/sensors/date_time.py
@@ -69,6 +69,7 @@ class DateTimeSensor(BaseSensorOperator):
raise TypeError(
f"Expected str or datetime.datetime type for target_time.
Got {type(target_time)}"
)
+ self.trigger =
DateTimeTrigger(moment=timezone.parse(self.target_time))
def poke(self, context: Context) -> bool:
self.log.info("Checking if the time (%s) has come",
self.target_time)
@@ -87,7 +88,7 @@ class DateTimeSensorAsync(DateTimeSensor):
def execute(self, context: Context):
self.defer(
-
trigger=DateTimeTrigger(moment=timezone.parse(self.target_time)),
+ trigger=self.trigger,
method_name="execute_complete",
)
```
This way the dag parsing will fail, and the user will fix the issue.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]