Enable validation for all Things and pick correct branch
This commit updates the branch to use Thing._class_settings instead of FEATURE_FLAGS for a safer way to implement new features.
This commit is contained in:
parent
05f92b9b33
commit
622fa17634
11 changed files with 20 additions and 4 deletions
|
|
@ -9,10 +9,6 @@ from typing import Optional, Self
|
||||||
|
|
||||||
import labthings_fastapi as lt
|
import labthings_fastapi as lt
|
||||||
|
|
||||||
# To ensure consistency, we enable the feature flags we want here. This means
|
|
||||||
# they will be enabled in any code that imports a `Thing` from this package.
|
|
||||||
lt.FEATURE_FLAGS.validate_properties_on_set = True
|
|
||||||
|
|
||||||
|
|
||||||
class OFMThing(lt.Thing):
|
class OFMThing(lt.Thing):
|
||||||
"""A custom LabThings Thing class for the OpenFlexure Microscope."""
|
"""A custom LabThings Thing class for the OpenFlexure Microscope."""
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,7 @@ class AutofocusThing(lt.Thing):
|
||||||
field of view to assess focus (autofocus and testing the success of a z-stack)
|
field of view to assess focus (autofocus and testing the success of a z-stack)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
_cam: BaseCamera = lt.thing_slot()
|
_cam: BaseCamera = lt.thing_slot()
|
||||||
_stage: BaseStage = lt.thing_slot()
|
_stage: BaseStage = lt.thing_slot()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ class ChannelBlankError(lt.exceptions.InvocationError):
|
||||||
class BackgroundDetectAlgorithm(lt.Thing):
|
class BackgroundDetectAlgorithm(lt.Thing):
|
||||||
"""The base class for defining background detect algorithms."""
|
"""The base class for defining background detect algorithms."""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
display_name: str = lt.property(default="Base Detector", readonly=True)
|
display_name: str = lt.property(default="Base Detector", readonly=True)
|
||||||
|
|
||||||
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,8 @@ class BaseCamera(OFMThing):
|
||||||
``__init__`` method of the subclass.
|
``__init__`` method of the subclass.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
_all_background_detectors: Mapping[str, BackgroundDetectAlgorithm] = lt.thing_slot()
|
_all_background_detectors: Mapping[str, BackgroundDetectAlgorithm] = lt.thing_slot()
|
||||||
|
|
||||||
mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
mjpeg_stream = lt.outputs.MJPEGStreamDescriptor()
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ class CameraStageMapper(lt.Thing):
|
||||||
override the ``get_xyz_position()`` and ``move_to_xyz_position()`` methods.
|
override the ``get_xyz_position()`` and ``move_to_xyz_position()`` methods.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
_cam: BaseCamera = lt.thing_slot()
|
_cam: BaseCamera = lt.thing_slot()
|
||||||
_stage: BaseStage = lt.thing_slot()
|
_stage: BaseStage = lt.thing_slot()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ from .stage.sangaboard import SangaboardThing
|
||||||
class Illumination(lt.Thing):
|
class Illumination(lt.Thing):
|
||||||
"""Base class for an illumination controller."""
|
"""Base class for an illumination controller."""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
@lt.action
|
@lt.action
|
||||||
def set_led(self, led_on: bool = True) -> None:
|
def set_led(self, led_on: bool = True) -> None:
|
||||||
"""Set the LED to on or off."""
|
"""Set the LED to on or off."""
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ class ScanWorkflow(Generic[SettingModelType], lt.Thing):
|
||||||
scan planning, acquisition routine.
|
scan planning, acquisition routine.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
display_name: str = lt.property(default="Base Workflow", readonly=True)
|
display_name: str = lt.property(default="Base Workflow", readonly=True)
|
||||||
ui_blurb: str = lt.property(
|
ui_blurb: str = lt.property(
|
||||||
default="If you see this message, something is wrong.", readonly=True
|
default="If you see this message, something is wrong.", readonly=True
|
||||||
|
|
@ -327,6 +329,8 @@ class SmartStackCompatibleSettings(Protocol):
|
||||||
class SmartStackMixin:
|
class SmartStackMixin:
|
||||||
"""A mixin for scan workflows that use smart stacking."""
|
"""A mixin for scan workflows that use smart stacking."""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
stack_images_to_save: int = lt.setting(default=1, ge=1, le=9)
|
stack_images_to_save: int = lt.setting(default=1, ge=1, le=9)
|
||||||
"""The number of images to save in a stack.
|
"""The number of images to save in a stack.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ class SmartScanThing(OFMThing):
|
||||||
past scans.
|
past scans.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
_cam: BaseCamera = lt.thing_slot()
|
_cam: BaseCamera = lt.thing_slot()
|
||||||
_stage: BaseStage = lt.thing_slot()
|
_stage: BaseStage = lt.thing_slot()
|
||||||
_all_workflows: Mapping[str, ScanWorkflow] = lt.thing_slot()
|
_all_workflows: Mapping[str, ScanWorkflow] = lt.thing_slot()
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ class BaseStage(lt.Thing):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_axis_names = ("x", "y", "z")
|
_axis_names = ("x", "y", "z")
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
def __init__(self, thing_server_interface: lt.ThingServerInterface) -> None:
|
||||||
"""Initialise the stage.
|
"""Initialise the stage.
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,8 @@ class ParasiticMotionError(lt.exceptions.InvocationError):
|
||||||
class RangeofMotionThing(lt.Thing):
|
class RangeofMotionThing(lt.Thing):
|
||||||
"""A class used to measure the range of motion of the stage in X and Y."""
|
"""A class used to measure the range of motion of the stage in X and Y."""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
_autofocus: AutofocusThing = lt.thing_slot()
|
_autofocus: AutofocusThing = lt.thing_slot()
|
||||||
_cam: BaseCamera = lt.thing_slot()
|
_cam: BaseCamera = lt.thing_slot()
|
||||||
_csm: CameraStageMapper = lt.thing_slot()
|
_csm: CameraStageMapper = lt.thing_slot()
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class OpenFlexureSystem(lt.Thing):
|
||||||
of the system.
|
of the system.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_class_settings = {"validate_properties_on_set": True}
|
||||||
|
|
||||||
_microscope_id: Optional[str] = None
|
_microscope_id: Optional[str] = None
|
||||||
|
|
||||||
@lt.setting
|
@lt.setting
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue