mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-12-19 12:41:19 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cac74e90db | ||
|
|
c24d63f4c0 | ||
|
|
b0dd5835a3 | ||
|
|
b0c8af0108 | ||
|
|
c0016673a8 | ||
|
|
eadc1df763 | ||
|
|
922fdf8fd0 | ||
|
|
8b21c42ef7 | ||
|
|
2399b3ca9f | ||
|
|
db43f5dbbb | ||
|
|
f2c0a94904 |
@@ -55,7 +55,7 @@ plugins:
|
||||
handlers:
|
||||
python:
|
||||
paths: [src] # search packages in the src folder
|
||||
import:
|
||||
inventories:
|
||||
- https://docs.python.org/3/objects.inv
|
||||
- https://docs.pydantic.dev/latest/objects.inv
|
||||
- https://confz.readthedocs.io/en/latest/objects.inv
|
||||
|
||||
1091
poetry.lock
generated
1091
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pydase"
|
||||
version = "0.10.10"
|
||||
version = "0.10.11"
|
||||
description = "A flexible and robust Python library for creating, managing, and interacting with data services, with built-in support for web and RPC servers, and customizable features for diverse use cases."
|
||||
authors = ["Mose Mueller <mosmuell@ethz.ch>"]
|
||||
readme = "README.md"
|
||||
@@ -39,9 +39,9 @@ optional = true
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs-material = "^9.5.30"
|
||||
mkdocs-include-markdown-plugin = "^3.9.1"
|
||||
mkdocstrings = {extras = ["python"], version = "^0.25.2"}
|
||||
mkdocstrings = {extras = ["python"], version = "^0.29.0"}
|
||||
pymdown-extensions = "^10.1"
|
||||
mkdocs-swagger-ui-tag = "^0.6.10"
|
||||
mkdocs-swagger-ui-tag = "^0.7.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
||||
@@ -55,6 +55,10 @@ class Observable(ObservableObject):
|
||||
value = super().__getattribute__(name)
|
||||
|
||||
if is_property_attribute(self, name):
|
||||
# fixes https://github.com/tiqi-group/pydase/issues/187 and
|
||||
# https://github.com/tiqi-group/pydase/issues/192
|
||||
if isinstance(value, ObservableObject):
|
||||
value.add_observer(self, name)
|
||||
self._notify_changed(name, value)
|
||||
|
||||
return value
|
||||
|
||||
@@ -87,8 +87,10 @@ class Server:
|
||||
service: The DataService instance that this server will manage.
|
||||
host: The host address for the server. Defaults to `'0.0.0.0'`, which means all
|
||||
available network interfaces.
|
||||
web_port: The port number for the web server. Defaults to
|
||||
[`ServiceConfig().web_port`][pydase.config.ServiceConfig.web_port].
|
||||
web_port: The port number for the web server. If set to None, it will use the
|
||||
port defined in
|
||||
[`ServiceConfig().web_port`][pydase.config.ServiceConfig.web_port]. Defaults
|
||||
to None.
|
||||
enable_web: Whether to enable the web server.
|
||||
filename: Filename of the file managing the service state persistence.
|
||||
additional_servers: A list of additional servers to run alongside the main
|
||||
@@ -140,7 +142,7 @@ class Server:
|
||||
self,
|
||||
service: DataService,
|
||||
host: str = "0.0.0.0",
|
||||
web_port: int = ServiceConfig().web_port,
|
||||
web_port: int | None = None,
|
||||
enable_web: bool = True,
|
||||
filename: str | Path | None = None,
|
||||
additional_servers: list[AdditionalServer] | None = None,
|
||||
@@ -151,7 +153,10 @@ class Server:
|
||||
additional_servers = []
|
||||
self._service = service
|
||||
self._host = host
|
||||
self._web_port = web_port
|
||||
if web_port is None:
|
||||
self._web_port = ServiceConfig().web_port
|
||||
else:
|
||||
self._web_port = web_port
|
||||
self._enable_web = enable_web
|
||||
self._kwargs = kwargs
|
||||
self._additional_servers = additional_servers
|
||||
|
||||
@@ -222,3 +222,22 @@ def test_nested_dict_property_changes(
|
||||
# Changing the _voltage attribute should re-evaluate the voltage property, but avoid
|
||||
# recursion
|
||||
service.my_dict["key"].voltage = 1.2
|
||||
|
||||
|
||||
def test_read_only_dict_property(caplog: pytest.LogCaptureFixture) -> None:
|
||||
class MyObservable(pydase.DataService):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self._dict_attr = {"dotted.key": 1.0}
|
||||
|
||||
@property
|
||||
def dict_attr(self) -> dict[str, Any]:
|
||||
return self._dict_attr
|
||||
|
||||
service_instance = MyObservable()
|
||||
state_manager = StateManager(service=service_instance)
|
||||
DataServiceObserver(state_manager)
|
||||
|
||||
service_instance._dict_attr["dotted.key"] = 2.0
|
||||
|
||||
assert "'dict_attr[\"dotted.key\"]' changed to '2.0'" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user