Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from collections.abc import Iterator
from os import environ
from unittest.mock import patch

import pytest

# Ensure that the blueapi entry point is not invoked by doctest as this will fail
collect_ignore = ["src/mx_bluesky/hyperion/blueapi/plans.py"]

environ["HYPERION_TEST_MODE"] = "true"


pytest_plugins = ["dodal.testing.fixtures.run_engine"]

Expand Down
9 changes: 0 additions & 9 deletions src/mx_bluesky/common/device_setup_plans/setup_panda.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/mx_bluesky/common/parameters/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
from semver import Version

from mx_bluesky.common.parameters.constants import (
TEST_MODE,
USE_NUMTRACKER,
DetectorParamConstants,
GridscanParamConstants,
)

Expand Down Expand Up @@ -158,11 +156,7 @@ class WithOptionalEnergyChange(BaseModel):
class WithVisit(BaseModel):
beamline: str = Field(default="BL03I", pattern=r"BL\d{2}[BIJS]")
visit: str = Field(min_length=1)
det_dist_to_beam_converter_path: str = Field(
default=DetectorParamConstants.BEAM_XY_LUT_PATH
)
detector_distance_mm: float | None = Field(default=None, gt=0)
insertion_prefix: str = "SR03S" if TEST_MODE else "SR03I"


class DiffractionExperiment(
Expand Down
12 changes: 1 addition & 11 deletions src/mx_bluesky/common/parameters/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
TEST_MODE = BEAMLINE == "test"
ZEBRA_STATUS_TIMEOUT = 30

GDA_DOMAIN_PROPERTIES_PATH = (
"tests/test_data/test_domain_properties"
if TEST_MODE
else (f"/dls_sw/{BEAMLINE}/software/daq_configuration/domain/domain.properties")
)


@dataclass(frozen=True)
class DocDescriptorNames:
Expand Down Expand Up @@ -126,11 +120,7 @@ class RotationParamConstants:

@dataclass(frozen=True)
class DetectorParamConstants:
BEAM_XY_LUT_PATH = (
"tests/test_data/test_det_dist_converter.txt"
if TEST_MODE
else f"/dls_sw/{BEAMLINE}/software/daq_configuration/lookup/DetDistToBeamXYConverter.txt"
)
BEAM_XY_LUT_PATH = f"/dls_sw/{BEAMLINE}/software/daq_configuration/lookup/DetDistToBeamXYConverter.txt"
DETECTOR = EIGER2_X_16M_SIZE


Expand Down
6 changes: 1 addition & 5 deletions src/mx_bluesky/common/parameters/gridscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ def specified_grid_params(self) -> SpecifiedGrids | None:
# must be the same for each grid
@property
def detector_params(self):
self.det_dist_to_beam_converter_path = (
self.det_dist_to_beam_converter_path
or DetectorParamConstants.BEAM_XY_LUT_PATH
)
optional_args = {}
if self.run_number:
optional_args["run_number"] = self.run_number
Expand All @@ -106,7 +102,7 @@ def detector_params(self):
num_images_per_trigger=1,
num_triggers=self.num_images,
use_roi_mode=self.use_roi_mode,
det_dist_to_beam_converter_path=self.det_dist_to_beam_converter_path,
det_dist_to_beam_converter_path=DetectorParamConstants.BEAM_XY_LUT_PATH,
trigger_mode=self.trigger_mode,
**optional_args,
)
Expand Down
6 changes: 1 addition & 5 deletions src/mx_bluesky/common/parameters/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ class RotationExperiment(DiffractionExperiment):
def _detector_params_impl(
self, omega_start_deg: float, num_images_per_trigger: int, num_triggers: int
) -> DetectorParams:
self.det_dist_to_beam_converter_path = (
self.det_dist_to_beam_converter_path
or DetectorParamConstants.BEAM_XY_LUT_PATH
)
optional_args = {}
if self.run_number:
optional_args["run_number"] = self.run_number
Expand All @@ -89,7 +85,7 @@ def _detector_params_impl(
num_images_per_trigger=num_images_per_trigger,
num_triggers=num_triggers,
use_roi_mode=False,
det_dist_to_beam_converter_path=self.det_dist_to_beam_converter_path,
det_dist_to_beam_converter_path=DetectorParamConstants.BEAM_XY_LUT_PATH,
**optional_args,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from dodal.common.types import UpdatingPathProvider
from dodal.devices.fast_grid_scan import PandAGridScanParams
from dodal.devices.smargon import Smargon
from dodal.plans.load_panda_yaml import load_panda_from_yaml
from ophyd_async.fastcs.panda import (
HDFPanda,
SeqTable,
SeqTrigger,
)

from mx_bluesky.common.device_setup_plans.setup_panda import load_panda_from_yaml
from mx_bluesky.common.parameters.constants import DeviceSettingsConstants
from mx_bluesky.common.utils.log import LOGGER

Expand Down
6 changes: 0 additions & 6 deletions src/mx_bluesky/hyperion/parameters/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from dodal.devices.detector import EIGER2_X_16M_SIZE
from pydantic.dataclasses import dataclass

Expand All @@ -13,14 +11,10 @@
PlanNameConstants,
)

TEST_MODE = os.environ.get("HYPERION_TEST_MODE")


@dataclass(frozen=True)
class I03Constants:
BEAMLINE = "BL03S" if TEST_MODE else "BL03I"
DETECTOR = EIGER2_X_16M_SIZE
INSERTION_PREFIX = "SR03S" if TEST_MODE else "SR03I"
OAV_CENTRING_FILE = OavConstants.OAV_CONFIG_JSON
SHUTTER_TIME_S = 0.06
USE_GPU_RESULTS = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"parameters": {
"parameter_model_version": "5.0.0",
"beamline": "BL03S",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"insertion_prefix": "SR03S",
"visit": "cm31105-4",
"detector_distance_mm": 255,
"sample_id": 12345,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"storage_directory": "/tmp",
"file_name": "file_name",
"run_number": 0,
"sample_id": 123456,
"use_roi_mode": false,
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"exposure_time_s": 0.1,
"detector_distance_mm": 100.0,
"omega_starts_deg": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"insertion_prefix": "SR03S",
"visit": "cm31105-4",
"detector_distance_mm": 255,
"sample_id": 12345,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"insertion_prefix": "SR03S",
"visit": "cm31105-4",
"detector_distance_mm": 255,
"sample_id": 12345,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"parameter_model_version": "6.0.0",
"comment": "test",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"storage_directory": "{tmp_data}/123456/",
"detector_distance_mm": 100.0,
"demand_energy_ev": 100,
"exposure_time_s": 0.1,
"insertion_prefix": "SR03S",
"file_name": "file_name",
"run_number": 0,
"shutter_opening_time_s": 0.6,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"parameter_model_version": "6.0.0",
"comment": "test",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"storage_directory": "{tmp_data}/123456/",
"detector_distance_mm": 100.0,
"demand_energy_ev": 100,
"exposure_time_s": 0.1,
"insertion_prefix": "SR03S",
"file_name": "file_name",
"visit": "cm31105-4",
"transmission_frac": 0.1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"parameter_model_version": "6.0.0",
"comment": "test",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"storage_directory": "{tmp_data}/123456/",
"detector_distance_mm": 100.0,
"demand_energy_ev": 100,
"exposure_time_s": 0.1,
"insertion_prefix": "SR03S",
"file_name": "file_name",
"rotation_increment_deg": 0.1,
"run_number": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"storage_directory": "/tmp",
"file_name": "file_name",
"run_number": 0,
"sample_id": 123456,
"use_roi_mode": false,
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"exposure_time_s": 0.1,
"detector_distance_mm": 100.0,
"omega_starts_deg": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"storage_directory": "/tmp/",
"visit": "cm31105-4",
"file_name": "file_name",
"run_number": 0,
"use_roi_mode": false,
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"omega_starts_deg": [
0,
90
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"snapshot_directory": "/tmp/",
"storage_directory": "/tmp/",
"visit": "cm31105-4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"parameter_model_version": "6.0.0",
"comment": "test",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"storage_directory": "{tmp_data}/123456/",
"detector_distance_mm": 100.0,
"demand_energy_ev": 100,
"exposure_time_s": 0.1,
"insertion_prefix": "SR03S",
"omega_starts_deg": [
0,
90
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
"parameter_model_version": "6.0.0",
"demand_energy_ev": 100,
"comment": "test",
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"detector_distance_mm": 100.0,
"visit": "cm31105-4",
"exposure_time_s": 0.1,
"insertion_prefix": "SR03S",
"omega_starts_deg": [
0,
90
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"storage_directory": "{tmp_data}",
"file_name": "file_name",
"run_number": 0,
"sample_id": 123456,
"use_roi_mode": false,
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"exposure_time_s": 0.12,
"detector_distance_mm": 100.0,
"omega_starts_deg": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"parameter_model_version": "6.0.0",
"beamline": "BL03S",
"insertion_prefix": "SR03S",
"demand_energy_ev": 100,
"storage_directory": "{tmp_data}",
"visit": "cm31105-4",
Expand All @@ -10,7 +9,6 @@
"run_number": 0,
"comment": "Descriptive comment.",
"use_roi_mode": false,
"det_dist_to_beam_converter_path": "tests/test_data/test_lookup_table.txt",
"transmission_frac": 1.0,
"x_steps": 40,
"y_steps": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

from bluesky.plan_stubs import null
from bluesky.run_engine import RunEngine
from dodal.plans.load_panda_yaml import load_panda_from_yaml
from ophyd_async.fastcs.panda import HDFPanda

from mx_bluesky.common.device_setup_plans.setup_panda import load_panda_from_yaml


def get_test_plan(*args):
yield from null()
return "retrieved_settings"


@patch("mx_bluesky.common.device_setup_plans.setup_panda.YamlSettingsProvider")
@patch("mx_bluesky.common.device_setup_plans.setup_panda.retrieve_settings")
@patch("mx_bluesky.common.device_setup_plans.setup_panda.apply_panda_settings")
@patch("dodal.plans.load_panda_yaml.YamlSettingsProvider")
@patch("dodal.plans.load_panda_yaml.retrieve_settings")
@patch("dodal.plans.load_panda_yaml.apply_panda_settings")
def test_load_panda_from_yaml(
mock_apply_panda_settings: MagicMock,
mock_retrieve_settings: MagicMock,
Expand Down
9 changes: 9 additions & 0 deletions tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ def create_gridscan_callbacks() -> tuple[
)


@pytest.fixture(autouse=True)
def mock_default_beam_xy_lut():
with patch(
"mx_bluesky.common.parameters.constants.DetectorParamConstants.BEAM_XY_LUT_PATH",
"tests/test_data/test_lookup_table.txt",
):
yield


@pytest.fixture
def use_beamline_t01():
"""Beamline t01 is a beamline for unit tests that just contains a baton, so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ def test_params_with_different_energy_for_rotation_gridscan_rejected(tmp_path):
# WithVisit
["beamline", "i03"],
["visit", "cm12345"],
["insertion_prefix", "SR03"],
["detector_distance_mm", 123],
["det_dist_to_beam_converter_path", "/foo/bar"],
],
)
def test_params_with_unexpected_info_in_robot_load_rejected(
Expand Down Expand Up @@ -308,9 +306,7 @@ def test_params_with_unexpected_info_in_robot_load_rejected(
# WithVisit
["beamline", "i03"],
["visit", "cm12345"],
["insertion_prefix", "SR03"],
["detector_distance_mm", 123],
["det_dist_to_beam_converter_path", "/foo/bar"],
],
)
def test_params_with_unexpected_info_in_multi_rotation_scan_rejected(
Expand Down
Loading
Loading