ferruzzi commented on code in PR #61461:
URL: https://github.com/apache/airflow/pull/61461#discussion_r2898414580


##########
airflow-core/src/airflow/serialization/definitions/deadline.py:
##########
@@ -239,6 +250,58 @@ def serialize_reference(self) -> dict:
         def deserialize_reference(cls, reference_data: dict):
             return cls(max_runs=reference_data["max_runs"], 
min_runs=reference_data.get("min_runs"))
 
+    class SerializedCustomReference(SerializedBaseDeadlineReference):
+        """
+        Wrapper for custom deadline references.
+
+        This class dynamically delegates to the wrapped reference for 
required_kwargs and evaluation logic.
+        """
+
+        def __init__(self, inner_ref):
+            self.inner_ref = inner_ref
+
+        @property
+        def reference_name(self) -> str:
+            return self.inner_ref.reference_name
+
+        def evaluate_with(self, *, session: Session, interval: timedelta, 
**kwargs: Any) -> datetime | None:
+            """Validate the provided kwargs and evaluate this deadline with 
the given conditions."""
+            required_kwargs: set[str] = getattr(self.inner_ref, 
"required_kwargs", set())
+            filtered_kwargs = {k: v for k, v in kwargs.items() if k in 
required_kwargs}
+
+            if missing_kwargs := required_kwargs - filtered_kwargs.keys():
+                raise ValueError(
+                    f"{self.inner_ref.__class__.__name__} is missing required 
parameters: {', '.join(missing_kwargs)}"
+                )
+
+            if extra_kwargs := kwargs.keys() - filtered_kwargs.keys():
+                self.log.debug("Ignoring unexpected parameters: %s", ", 
".join(extra_kwargs))

Review Comment:
   I know this was copypasta, but this message in the logs without context may 
be confusing.  Do we want a debug("Evaluating self.__name__") at the top of the 
method so this message has some frame of reference?



-- 
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]

Reply via email to