mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-05 21:20:40 +02:00
fixes loading of removed attributes. Prints debug log instead of raising exception
This commit is contained in:
parent
edb06b1612
commit
900017791a
@ -13,6 +13,7 @@ from pydase.utils.helpers import (
|
|||||||
)
|
)
|
||||||
from pydase.utils.serialization.deserializer import loads
|
from pydase.utils.serialization.deserializer import loads
|
||||||
from pydase.utils.serialization.serializer import (
|
from pydase.utils.serialization.serializer import (
|
||||||
|
SerializationPathError,
|
||||||
SerializedObject,
|
SerializedObject,
|
||||||
generate_serialized_data_paths,
|
generate_serialized_data_paths,
|
||||||
get_nested_dict_by_path,
|
get_nested_dict_by_path,
|
||||||
@ -299,12 +300,20 @@ class StateManager:
|
|||||||
)
|
)
|
||||||
return has_decorator
|
return has_decorator
|
||||||
|
|
||||||
cached_serialization_dict = get_nested_dict_by_path(
|
try:
|
||||||
self.cache_value, full_access_path
|
cached_serialization_dict = get_nested_dict_by_path(
|
||||||
)
|
self.cache_value, full_access_path
|
||||||
|
)
|
||||||
|
|
||||||
if cached_serialization_dict["value"] == "method":
|
if cached_serialization_dict["value"] == "method":
|
||||||
|
return False
|
||||||
|
|
||||||
|
# nested objects cannot be loaded
|
||||||
|
return not serialized_dict_is_nested_object(cached_serialization_dict)
|
||||||
|
except SerializationPathError:
|
||||||
|
logger.debug(
|
||||||
|
"Path %a could not be loaded. It does not correspond to an attribute of"
|
||||||
|
" the class. Ignoring value from JSON file...",
|
||||||
|
attr_name,
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# nested objects cannot be loaded
|
|
||||||
return not serialized_dict_is_nested_object(cached_serialization_dict)
|
|
||||||
|
@ -240,8 +240,8 @@ def test_load_state(tmp_path: Path, caplog: LogCaptureFixture) -> None:
|
|||||||
"Ignoring value from JSON file..."
|
"Ignoring value from JSON file..."
|
||||||
) in caplog.text
|
) in caplog.text
|
||||||
assert (
|
assert (
|
||||||
"Attribute type of 'removed_attr' changed from 'str' to 'None'. "
|
"Path 'removed_attr' could not be loaded. It does not correspond to an "
|
||||||
"Ignoring value from JSON file..." in caplog.text
|
"attribute of the class. Ignoring value from JSON file..." in caplog.text
|
||||||
)
|
)
|
||||||
assert "Value of attribute 'subservice.name' has not changed..." in caplog.text
|
assert "Value of attribute 'subservice.name' has not changed..." in caplog.text
|
||||||
assert "'my_slider.value' changed to '1.0'" in caplog.text
|
assert "'my_slider.value' changed to '1.0'" in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user