From 2b304cba039c33f842c57787b616d6b982861942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 6 Nov 2023 15:08:11 +0100 Subject: [PATCH] docs: updating docstrings --- src/pydase/data_service/state_manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pydase/data_service/state_manager.py b/src/pydase/data_service/state_manager.py index 40c0741..2fdee55 100644 --- a/src/pydase/data_service/state_manager.py +++ b/src/pydase/data_service/state_manager.py @@ -77,11 +77,10 @@ class StateManager: def save_state(self) -> None: """ - Serialize the DataService instance and write it to a JSON file. - - Args: - filename (str): The name of the file to write to. + Saves the DataService's current state to a JSON file defined by `self.filename`. + Logs an error if `self.filename` is not set. """ + if self.filename is not None: with open(self.filename, "w") as f: json.dump(self.cache, f, indent=4) @@ -92,6 +91,11 @@ class StateManager: ) def load_state(self) -> None: + """ + Loads the DataService's state from a JSON file defined by `self.filename`. + Updates the service's attributes, respecting type and read-only constraints. + """ + # Traverse the serialized representation and set the attributes of the class json_dict = self._get_state_dict_from_JSON_file() if json_dict == {}: