From f71cd27a68dc6868eb36e884a3456fa893030615 Mon Sep 17 00:00:00 2001 From: Igor Ghisi Date: Fri, 27 Oct 2023 17:09:24 -0300 Subject: [PATCH] Register Numpy serializer for Pyro client Rocky APP is now registering a serializer for Numpy arrays, so we have to make sure PyRocky correctly deserializes it. ROCKY-20273 --- src/ansys/rocky/prepost/client.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ansys/rocky/prepost/client.py b/src/ansys/rocky/prepost/client.py index 36b57f85..5536fcf7 100644 --- a/src/ansys/rocky/prepost/client.py +++ b/src/ansys/rocky/prepost/client.py @@ -38,14 +38,6 @@ def __init__(self, pyro_api, pool_id): self._pool_id = pool_id self._pyro_api = pyro_api - def GetNumpyCurve(self, curve_name, unit=None): - api = self._pyro_api - serpent_dicts = api.SendToApiElement( - self._pool_id, "GetNumpyCurve", curve_name, unit - ) - numpy_data = [serpent.tobytes(d) for d in serpent_dicts] - return tuple(pickle.loads(b) for b in numpy_data) - def __getattr__(self, attr_name: str) -> object: def CallProxy(*args, **kwargs): return self._pyro_api.SendToApiElement( @@ -67,8 +59,14 @@ def deserialize_api_error(classname, serialized): return RockyApiError(serialized["message"]) +def deserialize_numpy(classname, serialized): + bytes = serpent.tobytes(serialized["bytes"]) + return pickle.loads(bytes) + + Pyro5.api.register_dict_to_class("ApiElementProxy", _ApiElementProxy.deserialize) Pyro5.api.register_dict_to_class("RockyApiError", deserialize_api_error) +Pyro5.api.register_dict_to_class("ndarray", deserialize_numpy) Pyro5.api.register_class_to_dict(_ApiElementProxy, _ApiElementProxy.serialize)