mirror of
https://github.com/tiqi-group/pydase_service_base.git
synced 2025-04-19 16:10:02 +02:00
updates to pydase version 0.8.0
This commit is contained in:
parent
c02a979be4
commit
2eb5cba02a
@ -5,18 +5,11 @@ from typing import Any
|
||||
import pydase
|
||||
import pydase.components
|
||||
import pydase.units as u
|
||||
import pydase.version
|
||||
import tiqi_rpc
|
||||
from pydase.data_service.data_service_observer import DataServiceObserver
|
||||
import pydase.version
|
||||
|
||||
if pydase.version.__major__ == 0 and pydase.version.__minor__ > 7:
|
||||
from pydase.utils.helpers import get_object_attr_from_path
|
||||
else:
|
||||
from pydase.utils.helpers import get_object_attr_from_path_list
|
||||
|
||||
def get_object_attr_from_path(target_obj: Any, path: str) -> Any:
|
||||
return get_object_attr_from_path_list(target_obj, path.split("."))
|
||||
|
||||
from pydase.utils.helpers import get_object_attr_from_path # type: ignore
|
||||
from pydase.utils.serialization.types import SerializedObject
|
||||
|
||||
from pydase_service_base.ionizer_interface.rpc_interface import RPCInterface
|
||||
|
||||
@ -43,19 +36,19 @@ class IonizerServer:
|
||||
self.server.install_signal_handlers = lambda: None # type: ignore
|
||||
|
||||
def notify_ionizer(
|
||||
self, full_access_path: str, value: Any, cached_value: dict[str, Any]
|
||||
self, full_access_path: str, value: Any, cached_value: SerializedObject
|
||||
) -> None:
|
||||
"""This function notifies Ionizer about changed values.
|
||||
|
||||
Args:
|
||||
- parent_path (str): The parent path of the parameter.
|
||||
- attr_name (str): The name of the changed parameter.
|
||||
- value (Any): The value of the parameter.
|
||||
full_access_path (str):
|
||||
The full access path of the parameter.
|
||||
value (Any):
|
||||
The new value of the parameter.
|
||||
cached_value (SerializedObject):
|
||||
The serialized representation of the cached parameter.
|
||||
"""
|
||||
parent_path_list, attr_name = (
|
||||
full_access_path.split(".")[:-1],
|
||||
full_access_path.split(".")[-1],
|
||||
) # without classname
|
||||
attr_name = full_access_path.split(".")[-1]
|
||||
if isinstance(value, Enum):
|
||||
value = value.value
|
||||
if isinstance(value, u.Quantity):
|
||||
|
@ -6,17 +6,9 @@ from pydase import DataService
|
||||
from pydase.components import NumberSlider
|
||||
from pydase.data_service.data_service_observer import DataServiceObserver
|
||||
from pydase.units import Quantity
|
||||
import pydase.version
|
||||
|
||||
if pydase.version.__major__ == 0 and pydase.version.__minor__ > 7:
|
||||
from pydase.utils.helpers import get_object_attr_from_path
|
||||
else:
|
||||
from pydase.utils.helpers import get_object_attr_from_path_list
|
||||
|
||||
def get_object_attr_from_path(target_obj: Any, path: str) -> Any:
|
||||
return get_object_attr_from_path_list(target_obj, path.split("."))
|
||||
|
||||
|
||||
from pydase.utils.helpers import get_object_attr_from_path
|
||||
from pydase.utils.serialization.serializer import dump
|
||||
from pydase.utils.serialization.types import SerializedObject
|
||||
from pydase.version import __version__
|
||||
|
||||
|
||||
@ -36,8 +28,8 @@ class RPCInterface:
|
||||
async def name(self) -> str:
|
||||
return self._service.__class__.__name__
|
||||
|
||||
async def get_props(self) -> dict[str, Any]:
|
||||
return self._service.serialize()["value"]
|
||||
async def get_props(self) -> SerializedObject:
|
||||
return self._service.serialize()["value"] # type: ignore
|
||||
|
||||
async def get_param(self, full_access_path: str) -> Any:
|
||||
"""Returns the value of the parameter given by the full_access_path.
|
||||
@ -84,7 +76,9 @@ class RPCInterface:
|
||||
elif isinstance(current_value, NumberSlider):
|
||||
full_access_path = full_access_path + "value"
|
||||
|
||||
self._state_manager.set_service_attribute_value_by_path(full_access_path, value)
|
||||
self._state_manager.set_service_attribute_value_by_path(
|
||||
full_access_path, dump(value)
|
||||
)
|
||||
|
||||
async def remote_call(self, full_access_path: str, *args: Any) -> Any:
|
||||
method_object = get_object_attr_from_path(self._service, full_access_path)
|
||||
|
@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
confz = "^2.0.0"
|
||||
pydase = ">=0.6.0"
|
||||
pydase = ">=0.8.0"
|
||||
|
||||
# optional dependencies
|
||||
tiqi-rpc = { git = "ssh://git@gitlab.phys.ethz.ch/tiqi-projects/tiqi-rpc-python.git", optional = true }
|
||||
|
Loading…
x
Reference in New Issue
Block a user