Skip to content

Commit

Permalink
Use updated ApertureScatterguard
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester committed Sep 5, 2024
1 parent 7e52e28 commit 0b007bc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/mx_bluesky/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from enum import Enum

from dodal.devices.aperturescatterguard import AperturePositionGDANames
from dodal.devices.aperturescatterguard import ApertureValue
from dodal.devices.detector import EIGER2_X_16M_SIZE
from pydantic.dataclasses import dataclass

Expand Down Expand Up @@ -80,7 +80,7 @@ class GridscanParamConstants:

@dataclass(frozen=True)
class RotationParamConstants:
DEFAULT_APERTURE_POSITION = AperturePositionGDANames.LARGE_APERTURE
DEFAULT_APERTURE_POSITION = ApertureValue.LARGE


@dataclass(frozen=True)
Expand Down
6 changes: 2 additions & 4 deletions src/mx_bluesky/hyperion/parameters/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Annotated, Any

from annotated_types import Len
from dodal.devices.aperturescatterguard import AperturePositionGDANames
from dodal.devices.aperturescatterguard import ApertureValue
from dodal.devices.detector import DetectorParams
from dodal.devices.detector.det_dist_to_beam_converter import (
DetectorDistanceToBeamXYConverter,
Expand Down Expand Up @@ -83,9 +83,7 @@ def _detector_params(self, omega_start_deg: float):
)

@validator("selected_aperture")
def _set_default_aperture_position(
cls, aperture_position: AperturePositionGDANames | None
):
def _set_default_aperture_position(cls, aperture_position: ApertureValue | None):
if not aperture_position:
LOGGER.warning(
f"No aperture position selected. Defaulting to {RotationParamConstants.DEFAULT_APERTURE_POSITION}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@


@pytest.mark.parametrize(
"gda_position, set_position",
"set_position",
[
(AperturePositionGDANames.SMALL_APERTURE, AperturePosition.SMALL),
(AperturePositionGDANames.MEDIUM_APERTURE, AperturePosition.MEDIUM),
(AperturePositionGDANames.ROBOT_LOAD, AperturePosition.ROBOT_LOAD),
(AperturePositionGDANames.LARGE_APERTURE, AperturePosition.LARGE),
(ApertureValue.SMALL),
(ApertureValue.MEDIUM),
(ApertureValue.ROBOT_LOAD),
(ApertureValue.LARGE),
],
)
async def test_move_aperture_goes_to_correct_position(
aperture_scatterguard: ApertureScatterguard,
RE: RunEngine,
gda_position,
set_position,
):
with patch.object(aperture_scatterguard, "set") as mock_set:
RE(move_aperture_if_required(aperture_scatterguard, gda_position))
RE(move_aperture_if_required(aperture_scatterguard, set_position))
mock_set.assert_called_once_with(
set_position,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/hyperion/parameters/test_parameter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import pytest
from dodal.devices.aperturescatterguard import AperturePositionGDANames
from dodal.devices.aperturescatterguard import ApertureValue
from pydantic import ValidationError

from mx_bluesky.hyperion.parameters.constants import GridscanParamConstants
Expand Down Expand Up @@ -120,4 +120,4 @@ def test_selected_aperture_uses_default():
)
raw_params["selected_aperture"] = None
params = RotationScan(**raw_params)
assert params.selected_aperture == AperturePositionGDANames.LARGE_APERTURE
assert params.selected_aperture == ApertureValue.LARGE

0 comments on commit 0b007bc

Please sign in to comment.