You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/13 10:28:44 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #19505: Add params dag_id, task_id etc to XCom.serialize_value

uranusjr commented on a change in pull request #19505:
URL: https://github.com/apache/airflow/pull/19505#discussion_r783826687



##########
File path: airflow/models/xcom.py
##########
@@ -478,6 +489,27 @@ def orm_deserialize_value(self) -> Any:
         return BaseXCom.deserialize_value(self)
 
 
+def serialize_value_shim(**kwargs):
+    """
+    Previously XCom.serialize_value only accepted one argument ``value``.  In order to give
+    custom XCom backends more flexibility with how they store values we now forward to
+    ``XCom.serialize_value`` all params passed to ``XCom.set``.  In order to maintain
+    compatibility with XCom backends written with the old signature we need to use this
+    compatibility shim, which forwards only those kwargs which are accepted by the
+    XCom backend.
+    """
+    signature = inspect_function_arguments(XCom.serialize_value)
+    kwargs = {k: kwargs.get(k) for k in signature.bound_arguments}
+    if set(kwargs) == {'value'}:
+        warnings.warn(
+            f"Method `serialize_value` in XCom backend {XCom.__name__} is using outdated signature and"
+            f"must be updated to accept all params in `BaseXCom.set` except `session`.",

Review comment:
       ```suggestion
               f"Method `serialize_value` in XCom backend {XCom.__name__} is using outdated signature, "
               f"please update it to accept all params in `BaseXCom.set` except `session`.",
   ```
   
   Softer language since this is a deprecation warning, not a breakage error.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org