Lee-W commented on code in PR #33403:
URL: https://github.com/apache/airflow/pull/33403#discussion_r1295669974
##########
airflow/triggers/temporal.py:
##########
@@ -34,18 +35,30 @@ class DateTimeTrigger(BaseTrigger):
The provided datetime MUST be in UTC.
"""
- def __init__(self, moment: datetime.datetime):
+ def __init__(self, moment: datetime.datetime, *, soft_fail: bool = False)
-> None:
super().__init__()
+ skipping_message_postfix = "Skipping due to soft_fail is set to True."
if not isinstance(moment, datetime.datetime):
- raise TypeError(f"Expected datetime.datetime type for moment. Got
{type(moment)}")
+ message = f"Expected datetime.datetime type for moment. Got
{type(moment)}"
+ if soft_fail:
+ raise AirflowSkipException(f"{message}.
{skipping_message_postfix}")
+ raise TypeError(message)
# Make sure it's in UTC
elif moment.tzinfo is None:
- raise ValueError("You cannot pass naive datetimes")
+ message = "You cannot pass naive datetimes"
+ if soft_fail:
+ raise AirflowSkipException(f"{message}.
{skipping_message_postfix}")
Review Comment:
Or what do you think about my first commit?
https://github.com/apache/airflow/pull/33403/commits/b2f2662ae1a11ea928aad57acd2892c763c2db25
I was trying not to duplicate the check logic and thus moved it to the trigger
--
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]