aditya-rai-5 commented on code in PR #75584:
URL: https://github.com/apache/airflow/pull/75584#discussion_r4378798531


##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -1490,25 +1492,29 @@ def _is_excluded(cls, var: Any, attrname: str, op: 
SDKDAGNode) -> bool:
 
         schema_defaults = cls.get_schema_defaults("operator")
         if attrname in schema_defaults:
-            if schema_defaults[attrname] == var:
+            comparison_value = var.total_seconds() if isinstance(var, 
datetime.timedelta) else var
+            if schema_defaults[attrname] == comparison_value:
                 # If it also matches client_defaults, exclude (optimization)
                 client_defaults = cls.generate_client_defaults()
                 if attrname in client_defaults:
-                    if client_defaults[attrname] == var:
+                    if client_defaults[attrname] == comparison_value:
                         return True
                     # If client_defaults differs, preserve explicit override 
from user
                     # Example: default_args={"retries": 0}, schema default=0, 
client_defaults={"retries": 3}
-                    if client_defaults[attrname] != var:
-                        if op.has_dag():
-                            dag = op.dag
-                            if dag and attrname in dag.default_args and 
dag.default_args[attrname] == var:
+                    if client_defaults[attrname] != comparison_value:
+                        override_sources = (
+                            op.dag.default_args if op.has_dag() and op.dag 
else {},
+                            getattr(op, "_BaseOperator__init_kwargs", {}),
+                            getattr(op, "partial_kwargs", {}),

Review Comment:
   You're right that the general `partial_kwargs` lookup broadened this fix to 
unrelated fields such as `retries`. I've removed that lookup and its 
`retries=0` test case.
   
   The timedelta change still needs to preserve a task's 300-second retry delay 
when the client default is 120 seconds. Otherwise, recognizing 300 seconds as 
the schema default and omitting it would cause deserialization to restore 120 
seconds instead.
   
   The revised code handles this directly for timedelta values: matching client 
defaults are omitted first; a schema-matching value is omitted only if there is 
no differing client default. Other types retain the original override logic. 
The remaining round-trip tests cover ordinary and mapped tasks with timedelta, 
integer, and float retry-delay inputs.
   
   Ruff, whitespace checks, the local serialization/model tests, and the Java 
SDK serialization conformance check all pass. The revised changes have been 
pushed.
   



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