From e611840aca1c50146b6de01824034366d4c4ee7d Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Thu, 11 Jan 2024 19:53:08 +0000 Subject: [PATCH] Save microscope id as a string UUIDs don't serialise to JSON, so I'm now saving it as a plain string and reconstructing a UUID object when it's returned. Returning a UUID seems clearer than returning a string. --- src/openflexure_microscope_server/things/settings_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openflexure_microscope_server/things/settings_manager.py b/src/openflexure_microscope_server/things/settings_manager.py index bd05d08a..13592691 100644 --- a/src/openflexure_microscope_server/things/settings_manager.py +++ b/src/openflexure_microscope_server/things/settings_manager.py @@ -90,8 +90,8 @@ class SettingsManager(Thing): def microscope_id(self) -> UUID: """A unique identifier for this microscope""" if "microscope_id" not in self.thing_settings: - self.thing_settings["microscope_id"] = uuid4() - return self.thing_settings["microscope_id"] + self.thing_settings["microscope_id"] = str(uuid4()) + return UUID(self.thing_settings["microscope_id"]) @thing_action def get_things_state(self, metadata_getter: GetThingStates) -> Mapping: