SameerMesiah97 commented on code in PR #73294:
URL: https://github.com/apache/airflow/pull/73294#discussion_r4041877313
##########
task-sdk/src/airflow/sdk/definitions/deadline.py:
##########
@@ -154,14 +154,22 @@ def __init__(
callback: Callback,
name: str | None = None,
):
+ if not isinstance(interval, (timedelta, VariableInterval)):
+ raise ValueError(
+ f"Interval must be a `timedelta` or a `VariableInterval`,
received {type(interval).__name__}."
+ )
+
+ # Serializing blocks subclasses for security reasons, so isinstance is
too loose.
+ if type(callback) not in {AsyncCallback, SyncCallback}:
+ raise ValueError(
+ f"Callbacks must be `AsyncCallback` or `SyncCallback`,
received {type(callback).__name__}."
+ )
Review Comment:
So as you can see from the CI failures,
`test_serialize_deserialize_deadline_alert` is now failing because it has a
test case that passes `SerializedVariableInterval` into the `DeadlineAlert`
constructor. There are two ways we could fix this:
1. Include `SerializedVariableInterval` in this type check. However, this
would break the core/SDK separation, so I would not recommend it.
2. Remove the test case that uses `SerializedVariableInterval` as an
argument for the `DeadlineAlert` constructor.
I would opt for option 2, given that `DeadlineAlert` is a user-facing
construct and it does not appear to use `SerializedVariableInterval` anywhere
in the implementation. We can safely remove this test case as it does not cover
a realistic scenario; it was only added as more of a failsafe to ensure
serialization is idempotent.
--
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]