From a9ea237cf362c7ffc7e160ba944eff0e7ee788e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 30 Sep 2024 16:58:01 +0200 Subject: [PATCH] overrides serialize method in ProxyClass, getting it from remote service --- src/pydase/client/proxy_class.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/pydase/client/proxy_class.py b/src/pydase/client/proxy_class.py index 287d33c..79554e7 100644 --- a/src/pydase/client/proxy_class.py +++ b/src/pydase/client/proxy_class.py @@ -1,10 +1,13 @@ import asyncio import logging +from typing import cast import socketio # type: ignore import pydase.components from pydase.client.proxy_loader import ProxyClassMixin +from pydase.utils.helpers import get_attribute_doc +from pydase.utils.serialization.types import SerializedDataService, SerializedObject logger = logging.getLogger(__name__) @@ -48,3 +51,24 @@ class ProxyClass(ProxyClassMixin, pydase.components.DeviceConnection): super().__init__() pydase.components.DeviceConnection.__init__(self) self._initialise(sio_client=sio_client, loop=loop) + + def serialize(self) -> SerializedObject: + readonly = False + doc = get_attribute_doc(self) + obj_name = self.__class__.__name__ + serialization_future = cast( + asyncio.Future[SerializedDataService], + asyncio.run_coroutine_threadsafe( + self._sio.call("service_serialization"), self._loop + ), + ) + value = serialization_future.result()["value"] + + return { + "full_access_path": "", + "name": obj_name, + "type": "DeviceConnection", + "value": value, + "readonly": readonly, + "doc": doc, + }