Docstrings and tweaks of ScanWorflow refactor

This commit is contained in:
Julian Stirling 2026-01-15 22:00:15 +00:00
parent c938560f00
commit 11ef1217e0
4 changed files with 16 additions and 16 deletions

View file

@ -59,7 +59,7 @@ class BaseScanData(BaseModel):
ScanWorkflow ScanWorkflow
* HistoricScanData which has the workflow specific data loaded as a dictionary. * 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 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 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 creating a ScanInfo object for communicating with the UI. These uses are clearly

View file

@ -567,7 +567,7 @@ class AutofocusThing(lt.Thing):
"""Capture a series of images checking that sharpest image central. """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 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. autofocussing, and retrying.
The images are separated in z offset by stack_parameters.stack_dz, as they The images are separated in z offset by stack_parameters.stack_dz, as they

View file

@ -40,13 +40,13 @@ SettingModelType = TypeVar("SettingModelType", bound=BaseModel)
class ScanWorkflow(Generic[SettingModelType], lt.Thing): class ScanWorkflow(Generic[SettingModelType], lt.Thing):
"""A base class for all Scanworkflows. """A base class for all Scanworkflows.
Scan workflows set the behaviour of a scan, inclduing the background detection, Scan workflows set the behaviour of a scan, including the background detection,
scan planning, aquisition routine. scan planning, acquisition routine.
""" """
_settings_model: type[SettingModelType] _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] _planner_cls: type[ScanPlanner]
# All workflows set a save resolution # 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." "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] self, settings: SettingModelType, xyz_pos: tuple[int, int, int]
) -> tuple[bool, Optional[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( raise NotImplementedError(
"Each specific ScanWorkflow must implement an aquisition routine" "Each specific ScanWorkflow must implement an acquisition routine"
) )
class HistoScanSettingsModel(BaseModel): class HistoScanSettingsModel(BaseModel):
"""The settings for a scan with the HistoScanWorkflow. """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. during a scan and serialised to disk.
""" """
@ -188,7 +188,7 @@ class HistoScanWorkflow(ScanWorkflow[HistoScanSettingsModel]):
* 200 for 20x * 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. # with other workflows that may want to validate the scan name.
def check_before_start(self, scan_name: str) -> None: # noqa: ARG002 def check_before_start(self, scan_name: str) -> None: # noqa: ARG002
"""Before starting a scan, check that background and camera-stage-mapping are set. """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, planner_settings=planner_settings,
) )
def aquisition_routine( def acquisition_routine(
self, settings: HistoScanSettingsModel, xyz_pos: tuple[int, int, int] self, settings: HistoScanSettingsModel, xyz_pos: tuple[int, int, int]
) -> tuple[bool, Optional[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 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. :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. If failed to find focus, returns for the focus z-position.
""" """

View file

@ -179,8 +179,8 @@ class SmartScanThing(lt.Thing):
def sample_scan(self, scan_name: str = "") -> None: def sample_scan(self, scan_name: str = "") -> None:
"""Move the stage to cover an area, taking images. """Move the stage to cover an area, taking images.
Depending on the way the stage moves depends on the selected worflow. Depending on the way the stage moves depends on the selected workflow.
If images overlap for a scan workdlow then the images can be stitched together If images overlap for a scan workflow then the images can be stitched together
into a larger composite image. into a larger composite image.
""" """
got_lock = self._scan_lock.acquire(timeout=0.1) got_lock = self._scan_lock.acquire(timeout=0.1)
@ -383,7 +383,7 @@ class SmartScanThing(lt.Thing):
new_pos_xyz[1], new_pos_xyz[1],
self._stage.position["z"], self._stage.position["z"],
) )
imaged, focus_height = workflow.aquisition_routine( imaged, focus_height = workflow.acquisition_routine(
workflow_settings, current_pos_xyz workflow_settings, current_pos_xyz
) )