From f7612e056c00aba62c01b4f30a3b7fe5d721290a Mon Sep 17 00:00:00 2001 From: Oliver Silvester Date: Thu, 22 Aug 2024 11:28:33 +0100 Subject: [PATCH] Revert "Use default value instead of validator" This reverts commit 8e2bb7356f22e64eed3f148d244683f4dc8437e2. --- src/hyperion/parameters/rotation.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/hyperion/parameters/rotation.py b/src/hyperion/parameters/rotation.py index 6785591fb..59e0b1e5e 100644 --- a/src/hyperion/parameters/rotation.py +++ b/src/hyperion/parameters/rotation.py @@ -14,7 +14,8 @@ from dodal.devices.zebra import ( RotationDirection, ) -from pydantic import Field, root_validator +from dodal.log import LOGGER +from pydantic import Field, root_validator, validator from scanspec.core import AxesPoints from scanspec.core import Path as ScanPath from scanspec.specs import Line @@ -50,9 +51,6 @@ class RotationExperiment(DiffractionExperimentWithSample): ispyb_experiment_type: IspybExperimentType = Field( default=IspybExperimentType.ROTATION ) - selected_aperture: AperturePositionGDANames | None = Field( - default=DEFAULT_APERTURE_POSITION - ) def _detector_params(self, omega_start_deg: float): self.det_dist_to_beam_converter_path = ( @@ -83,6 +81,18 @@ def _detector_params(self, omega_start_deg: float): **optional_args, ) + @validator("selected_aperture") + def _set_default_aperture_position( + cls, aperture_position: AperturePositionGDANames | None + ): + if not aperture_position: + LOGGER.warn( + f"No aperture position selected. Defaulting to {DEFAULT_APERTURE_POSITION}" + ) + return DEFAULT_APERTURE_POSITION + else: + return aperture_position + class RotationScan(WithScan, RotationScanPerSweep, RotationExperiment): @property