Andrushika commented on code in PR #77523:
URL: https://github.com/apache/airflow/pull/77523#discussion_r4676739744
##########
task-sdk/src/airflow/sdk/serde/serializers/kubernetes.py:
##########
@@ -55,10 +57,45 @@ def safe_get_name(pod):
return None
try:
- return PodGenerator.serialize_pod(o), qualname(o), __version__,
True
+ return ApiClient().sanitize_for_serialization(o), qualname(o),
__version__, True
except Exception:
log.warning("Serialization failed for pod %s", safe_get_name(o))
log.debug("traceback for serialization error", exc_info=True)
return "", "", 0, False
return "", "", 0, False
+
+
+def deserialize(cls: type, version: int, data: dict) -> Any:
+ import pydantic
+
+ if version > __version__:
+ raise TypeError(f"serialized version {version} is newer than class
version {__version__}")
+
+ if not hasattr(cls, "model_validate"):
+ raise TypeError(f"do not know how to deserialize {qualname(cls)}")
+
+ try:
+ return cls.model_validate(data)
+ except pydantic.ValidationError as e:
+ try:
+ coerced = _coerce_legacy_values(data, e)
+ except (KeyError, IndexError, TypeError):
Review Comment:
Nit: while touching this tuple -- when would `IndexError` happen? (IIUC the
index always comes from the data itself)
--
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]