From 11ef1217e027f2eeac7b8ca839afe7f232756d2f Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Thu, 15 Jan 2026 22:00:15 +0000 Subject: [PATCH] Docstrings and tweaks of ScanWorflow refactor --- .../scan_directories.py | 2 +- .../things/autofocus.py | 2 +- .../things/scan_workflows.py | 22 +++++++++---------- .../things/smart_scan.py | 6 ++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/openflexure_microscope_server/scan_directories.py b/src/openflexure_microscope_server/scan_directories.py index 1a2d25ff..50acfe2f 100644 --- a/src/openflexure_microscope_server/scan_directories.py +++ b/src/openflexure_microscope_server/scan_directories.py @@ -59,7 +59,7 @@ class BaseScanData(BaseModel): ScanWorkflow * HistoricScanData which has the workflow specific data loaded as a dictionary. - Sepearating historic and active data allows workflows to use any BaseModel for its + Separating historic and active data allows workflows to use any BaseModel for its settings, but for the data to be reloaded even if that model has updated or is not available. Historic scan data loaded from disk is used for stitching and for creating a ScanInfo object for communicating with the UI. These uses are clearly diff --git a/src/openflexure_microscope_server/things/autofocus.py b/src/openflexure_microscope_server/things/autofocus.py index 5a95b3de..76779aa9 100644 --- a/src/openflexure_microscope_server/things/autofocus.py +++ b/src/openflexure_microscope_server/things/autofocus.py @@ -567,7 +567,7 @@ class AutofocusThing(lt.Thing): """Capture a series of images checking that sharpest image central. This is part of run_smart_stack. This is the actual z_stackng stacking method - called by the action run_smart_stack. The action also handles reseting, + called by the action run_smart_stack. The action also handles resetting, autofocussing, and retrying. The images are separated in z offset by stack_parameters.stack_dz, as they diff --git a/src/openflexure_microscope_server/things/scan_workflows.py b/src/openflexure_microscope_server/things/scan_workflows.py index 17e03147..39548663 100644 --- a/src/openflexure_microscope_server/things/scan_workflows.py +++ b/src/openflexure_microscope_server/things/scan_workflows.py @@ -40,13 +40,13 @@ SettingModelType = TypeVar("SettingModelType", bound=BaseModel) class ScanWorkflow(Generic[SettingModelType], lt.Thing): """A base class for all Scanworkflows. - Scan workflows set the behaviour of a scan, inclduing the background detection, - scan planning, aquisition routine. + Scan workflows set the behaviour of a scan, including the background detection, + scan planning, acquisition routine. """ _settings_model: type[SettingModelType] - # All workdlows must have a set class for scan planning + # All workflows must have a set class for scan planning _planner_cls: type[ScanPlanner] # All workflows set a save resolution @@ -98,19 +98,19 @@ class ScanWorkflow(Generic[SettingModelType], lt.Thing): "Each specific ScanWorkflow must implement a ``new_scan_planner`` method." ) - def aquisition_routine( + def acquisition_routine( self, settings: SettingModelType, xyz_pos: tuple[int, int, int] ) -> tuple[bool, Optional[int]]: - """Overload to set the aquisition routine that happens at each scan site.""" + """Overload to set the acquisition routine that happens at each scan site.""" raise NotImplementedError( - "Each specific ScanWorkflow must implement an aquisition routine" + "Each specific ScanWorkflow must implement an acquisition routine" ) class HistoScanSettingsModel(BaseModel): """The settings for a scan with the HistoScanWorkflow. - This includes settings caluclated when starting. This will be held by smart scan + This includes settings calculated when starting. This will be held by smart scan during a scan and serialised to disk. """ @@ -188,7 +188,7 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]): * 200 for 20x """ - # The noqa statment is because scan_name is unused but is needed for equivalence + # The noqa statement is because scan_name is unused but is needed for equivalence # with other workflows that may want to validate the scan name. def check_before_start(self, scan_name: str) -> None: # noqa: ARG002 """Before starting a scan, check that background and camera-stage-mapping are set. @@ -389,13 +389,13 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]): planner_settings=planner_settings, ) - def aquisition_routine( + def acquisition_routine( self, settings: HistoScanSettingsModel, xyz_pos: tuple[int, int, int] ) -> tuple[bool, Optional[int]]: - """Perform aquisition routine. This is run at each scan location. + """Perform acquisition routine. This is run at each scan location. :param settings: The settings for this scan as a HistoScanSettingsModel - :param xyz_position: The current position as a tuple or 3 ints. + :param xyz_pos: The current position as a tuple or 3 ints. :return: A tuple of whether an image was taken, and the z-position for focus. If failed to find focus, returns for the focus z-position. """ diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index da23f422..3df18ad3 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -179,8 +179,8 @@ class SmartScanThing(lt.Thing): def sample_scan(self, scan_name: str = "") -> None: """Move the stage to cover an area, taking images. - Depending on the way the stage moves depends on the selected worflow. - If images overlap for a scan workdlow then the images can be stitched together + Depending on the way the stage moves depends on the selected workflow. + If images overlap for a scan workflow then the images can be stitched together into a larger composite image. """ got_lock = self._scan_lock.acquire(timeout=0.1) @@ -383,7 +383,7 @@ class SmartScanThing(lt.Thing): new_pos_xyz[1], self._stage.position["z"], ) - imaged, focus_height = workflow.aquisition_routine( + imaged, focus_height = workflow.acquisition_routine( workflow_settings, current_pos_xyz )