mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-14 08:17:15 +02:00
uses new serializer method to check if attribute is loadable
This commit is contained in:
@ -9,12 +9,14 @@ import pydase.units as u
|
|||||||
from pydase.data_service.data_service_cache import DataServiceCache
|
from pydase.data_service.data_service_cache import DataServiceCache
|
||||||
from pydase.utils.helpers import (
|
from pydase.utils.helpers import (
|
||||||
get_object_attr_from_path_list,
|
get_object_attr_from_path_list,
|
||||||
|
is_property_attribute,
|
||||||
parse_list_attr_and_index,
|
parse_list_attr_and_index,
|
||||||
)
|
)
|
||||||
from pydase.utils.serializer import (
|
from pydase.utils.serializer import (
|
||||||
dump,
|
dump,
|
||||||
generate_serialized_data_paths,
|
generate_serialized_data_paths,
|
||||||
get_nested_dict_by_path,
|
get_nested_dict_by_path,
|
||||||
|
serialized_dict_is_nested_object,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -246,7 +248,7 @@ class StateManager:
|
|||||||
else:
|
else:
|
||||||
setattr(target_obj, attr_name, value)
|
setattr(target_obj, attr_name, value)
|
||||||
|
|
||||||
def __is_loadable_state_attribute(self, property_path: str) -> bool:
|
def __is_loadable_state_attribute(self, full_access_path: str) -> bool:
|
||||||
"""Checks if an attribute defined by a dot-separated path should be loaded from
|
"""Checks if an attribute defined by a dot-separated path should be loaded from
|
||||||
storage.
|
storage.
|
||||||
|
|
||||||
@ -255,13 +257,12 @@ class StateManager:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
parent_object = get_object_attr_from_path_list(
|
parent_object = get_object_attr_from_path_list(
|
||||||
self.service, property_path.split(".")[:-1]
|
self.service, full_access_path.split(".")[:-1]
|
||||||
)
|
)
|
||||||
attr_name = property_path.split(".")[-1]
|
attr_name = full_access_path.split(".")[-1]
|
||||||
|
|
||||||
prop = getattr(type(parent_object), attr_name, None)
|
if is_property_attribute(parent_object, attr_name):
|
||||||
|
prop = getattr(type(parent_object), attr_name)
|
||||||
if isinstance(prop, property):
|
|
||||||
has_decorator = has_load_state_decorator(prop)
|
has_decorator = has_load_state_decorator(prop)
|
||||||
if not has_decorator:
|
if not has_decorator:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
@ -270,4 +271,10 @@ class StateManager:
|
|||||||
attr_name,
|
attr_name,
|
||||||
)
|
)
|
||||||
return has_decorator
|
return has_decorator
|
||||||
return True
|
|
||||||
|
cached_serialization_dict = get_nested_dict_by_path(
|
||||||
|
self.cache, full_access_path
|
||||||
|
)
|
||||||
|
|
||||||
|
# nested objects cannot be loaded
|
||||||
|
return not serialized_dict_is_nested_object(cached_serialization_dict)
|
||||||
|
Reference in New Issue
Block a user