From f6691cbc11acff04a76ce8c32f947e7ab9c0a75c Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Tue, 21 Mar 2023 15:05:21 +0000 Subject: [PATCH 1/4] Update openapi.py with live links to WoT documentation --- openflexure_microscope/api/openapi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openflexure_microscope/api/openapi.py b/openflexure_microscope/api/openapi.py index f0605954..77677740 100644 --- a/openflexure_microscope/api/openapi.py +++ b/openflexure_microscope/api/openapi.py @@ -8,8 +8,8 @@ API_TAGS = [ "embedded in the JSON action description." ), "externalDocs": { - "url": "https://iot.mozilla.org/wot/#action-resource", - "description": "Mozilla's description of Web of Things 'Action' resources.", + "url": "https://www.w3.org/TR/wot-thing-description/#actionaffordance", + "description": "w3's description of Web of Things 'Action' resources.", }, }, { @@ -19,8 +19,8 @@ API_TAGS = [ "state of the microscope." ), "externalDocs": { - "url": "https://iot.mozilla.org/wot/#property-resource", - "description": "Mozilla's description of Web of Things 'Property' resources.", + "url": "https://www.w3.org/TR/wot-thing-description/#propertyaffordance", + "description": "w3's description of Web of Things 'Property' resources.", }, }, {"name": "captures", "description": ""}, From 824248583d60f7103a0b87031a58c31d8d501708 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Tue, 21 Mar 2023 15:05:22 +0000 Subject: [PATCH 2/4] Add !154 to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a1b877c..b87bff32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## New features * Background detection can now be used in scans, if you have the background-detect extension. ([!153](https://gitlab.com/openflexure/openflexure-microscope-server/-/merge_requests/153)) * Support for Sangaboard firmware v1, via updated `sangaboard` dependency ([!154](https://gitlab.com/openflexure/openflexure-microscope-server/-/merge_requests/154)) +* Fixed links in the OpenAPI documentation describing actions etc. ([!155](https://gitlab.com/openflexure/openflexure-microscope-server/-/merge_requests/154)) # [v2.10.1](https://gitlab.com/openflexure/openflexure-microscope-server/compare/v2.10.0...v2.10.1) (2022-01-17) ## Bug fixes From 4b73fd82f6e66f80da3bc63e2b792b6b9fca717e Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Tue, 21 Mar 2023 15:11:24 +0000 Subject: [PATCH 3/4] Format fix --- openflexure_microscope/camera/pi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openflexure_microscope/camera/pi.py b/openflexure_microscope/camera/pi.py index 6052363b..f3a1db16 100644 --- a/openflexure_microscope/camera/pi.py +++ b/openflexure_microscope/camera/pi.py @@ -307,7 +307,9 @@ class PiCameraStreamer(BaseCamera): self.picamera.zoom = new_fov def start_preview( - self, fullscreen: bool = True, window: Optional[Tuple[int, int, int, int]] = None + self, + fullscreen: bool = True, + window: Optional[Tuple[int, int, int, int]] = None, ): """Start the on board GPU camera preview.""" with self.lock(timeout=1): From 1f558bbeb7096c2b6b859a5a28a59342d594463e Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Wed, 22 Mar 2023 08:58:04 +0000 Subject: [PATCH 4/4] OpenAPI Validation Fixes OpenAPI validation seems to have become stricter about checking for None defaults in parameters that don't allow None. I have modified two things as a result: 1. StageTypeProperty (used to pick between SangaStage and SangaDeltaStage) now defaults to SangaStage (which is the original behaviour anyway) 2. It is now allowed to pass x,y,z=None when making a move - this is the same as not passing the respective argument, so the function already correctly handled this case. --- openflexure_microscope/api/v2/views/actions/stage.py | 6 +++--- openflexure_microscope/api/v2/views/stage.py | 2 +- openflexure_microscope/camera/pi.py | 2 +- openflexure_microscope/config.py | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/openflexure_microscope/api/v2/views/actions/stage.py b/openflexure_microscope/api/v2/views/actions/stage.py index d13774ab..20412a6f 100644 --- a/openflexure_microscope/api/v2/views/actions/stage.py +++ b/openflexure_microscope/api/v2/views/actions/stage.py @@ -10,9 +10,9 @@ class MoveStageAPI(ActionView): load_default=False, metadata={"description": "Move to an absolute position", "example": False}, ), - "x": fields.Int(load_default=None, metadata={"example": 100}, allow_none=False), - "y": fields.Int(load_default=None, metadata={"example": 100}, allow_none=False), - "z": fields.Int(load_default=None, metadata={"example": 20}, allow_none=False), + "x": fields.Int(load_default=None, metadata={"example": 100}, allow_none=True), + "y": fields.Int(load_default=None, metadata={"example": 100}, allow_none=True), + "z": fields.Int(load_default=None, metadata={"example": 20}, allow_none=True), } def post(self, args): diff --git a/openflexure_microscope/api/v2/views/stage.py b/openflexure_microscope/api/v2/views/stage.py index bcfec3a9..c6437a24 100644 --- a/openflexure_microscope/api/v2/views/stage.py +++ b/openflexure_microscope/api/v2/views/stage.py @@ -7,7 +7,7 @@ class StageTypeProperty(PropertyView): """The type of the stage""" schema = fields.String( - load_default=None, + load_default="SangaStage", validate=validate.OneOf(["SangaStage", "SangaDeltaStage"]), metadata={ "description": "The translation stage geometry", diff --git a/openflexure_microscope/camera/pi.py b/openflexure_microscope/camera/pi.py index f3a1db16..e46360fa 100644 --- a/openflexure_microscope/camera/pi.py +++ b/openflexure_microscope/camera/pi.py @@ -30,7 +30,7 @@ import logging import time # Type hinting -from typing import BinaryIO, Tuple, Union, Optional +from typing import BinaryIO, Optional, Tuple, Union import numpy as np diff --git a/openflexure_microscope/config.py b/openflexure_microscope/config.py index 8ceed138..b2db8546 100644 --- a/openflexure_microscope/config.py +++ b/openflexure_microscope/config.py @@ -5,7 +5,6 @@ import os import shutil from typing import Optional - from .json import JSONEncoder from .paths import CONFIGURATION_FILE_PATH, SETTINGS_FILE_PATH