mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
adds ProxyClass serialization support
This commit is contained in:
parent
f47a183c11
commit
e2ce0e9acb
@ -42,6 +42,8 @@ from pydase.utils.serialization.types import (
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
|
||||
from pydase.client.proxy_class import ProxyClass
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -74,6 +76,7 @@ class Serializer:
|
||||
Returns:
|
||||
Dictionary representation of `obj`.
|
||||
"""
|
||||
from pydase.client.client import ProxyClass
|
||||
|
||||
result: SerializedObject
|
||||
|
||||
@ -83,6 +86,9 @@ class Serializer:
|
||||
elif isinstance(obj, datetime):
|
||||
result = cls._serialize_datetime(obj, access_path=access_path)
|
||||
|
||||
elif isinstance(obj, ProxyClass):
|
||||
result = cls._serialize_proxy_class(obj, access_path=access_path)
|
||||
|
||||
elif isinstance(obj, AbstractDataService):
|
||||
result = cls._serialize_data_service(obj, access_path=access_path)
|
||||
|
||||
@ -322,6 +328,13 @@ class Serializer:
|
||||
"doc": doc,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def _serialize_proxy_class(
|
||||
cls, obj: ProxyClass, access_path: str = ""
|
||||
) -> SerializedDataService:
|
||||
# Get serialization value from the remote service and adapt the full_access_path
|
||||
return add_prefix_to_full_access_path(obj.serialize(), access_path + ".")
|
||||
|
||||
|
||||
def dump(obj: Any) -> SerializedObject:
|
||||
"""Serialize `obj` to a
|
||||
|
Loading…
x
Reference in New Issue
Block a user