Skip to content

Commit ab5ce12

Browse files
authored
Use config server for oav config (#1521)
* Pin dodal * Simplify OAV test config * Inject config client into OAVConfig and OAVConfigBeamCentre * Restore test images * Update dls-dodal dependency to use main branch
1 parent 62c0c9a commit ab5ce12

23 files changed

Lines changed: 312 additions & 301 deletions

File tree

src/mx_bluesky/beamlines/i24/web_gui_plans/general_plans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def gui_stage_move_on_click(
8787

8888
@bpp.run_decorator()
8989
def gui_gonio_move_on_click(position_px: tuple[int, int]) -> MsgGenerator:
90-
oav = i24.oav()
90+
oav = i24.oav(i24.config_client())
9191
gonio = i24.vgonio()
9292

9393
x_microns_per_pixel = yield from bps.rd(oav.microns_per_pixel_x)

src/mx_bluesky/common/parameters/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from dodal.devices.zocalo.zocalo_constants import ZOCALO_ENV as ZOCALO_ENV_FROM_DODAL
77
from dodal.utils import get_beamline_name
88
from pydantic.dataclasses import dataclass
9+
from tests.test_data.oav import TEST_OAV_CENTRING_JSON
910

1011
from mx_bluesky.definitions import ROOT_DIR
1112

@@ -40,7 +41,7 @@ class DocDescriptorNames:
4041

4142
def _get_oav_config_json_path():
4243
if TEST_MODE:
43-
return "tests/test_data/test_OAVCentring.json"
44+
return TEST_OAV_CENTRING_JSON
4445
elif BEAMLINE == "i03":
4546
return f"/dls_sw/{BEAMLINE}/software/daq_configuration/json/OAVCentring_hyperion.json"
4647
elif BEAMLINE == "aithre":

tests/conftest.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from functools import partial
99
from pathlib import Path
1010
from types import ModuleType
11-
from typing import Any, TypeVar
11+
from typing import Any, TypedDict, TypeVar
1212
from unittest.mock import MagicMock, patch
1313

1414
import bluesky.plan_stubs as bps
@@ -116,6 +116,13 @@
116116
HyperionFlyScanXRayCentreComposite,
117117
)
118118
from mx_bluesky.hyperion.parameters.gridscan import HyperionSpecifiedThreeDGridScan
119+
from tests.test_data.oav import (
120+
TEST_DISPLAY_CONFIG,
121+
TEST_OAV_CENTRING_JSON,
122+
TEST_OAV_ZOOM_LEVELS,
123+
)
124+
125+
TEST_BEAMLINE_PARAMETERS = "tests/test_data/test_beamline_parameters.txt"
119126

120127
pytest_plugins = ["tests.expeye_helpers"]
121128

@@ -223,6 +230,13 @@
223230
}
224231
]
225232

233+
MOCK_DAQ_CONFIG_PATH = "tests/test_data/test_daq_configuration"
234+
mock_paths = [
235+
("DAQ_CONFIGURATION_PATH", MOCK_DAQ_CONFIG_PATH),
236+
("ZOOM_PARAMS_FILE", TEST_OAV_ZOOM_LEVELS),
237+
("DISPLAY_CONFIG", TEST_DISPLAY_CONFIG),
238+
]
239+
226240

227241
@dataclass(frozen=True)
228242
class SimConstants:
@@ -364,7 +378,7 @@ def _pass_on_mock(value: float, wait: bool):
364378

365379
@pytest.fixture
366380
def beamline_parameters():
367-
with Path("tests/test_data/test_beamline_parameters.txt").open("r") as f:
381+
with Path(TEST_BEAMLINE_PARAMETERS).open("r") as f:
368382
contents = f.read()
369383
return json.loads(contents)
370384

@@ -478,7 +492,9 @@ def synchrotron():
478492
@pytest.fixture
479493
def oav(test_config_files):
480494
parameters = OAVConfigBeamCentre(
481-
test_config_files["zoom_params_file"], test_config_files["display_config"]
495+
test_config_files["zoom_params_file"],
496+
test_config_files["display_config"],
497+
ConfigClient(""),
482498
)
483499
oav = i03.oav.build(mock=True, connect_immediately=True, params=parameters)
484500

@@ -562,8 +578,8 @@ def beamstop_phase1(
562578
sim_run_engine: RunEngineSimulator,
563579
) -> Generator[Beamstop, Any, Any]:
564580
with patch(
565-
"dodal.beamlines.i03.get_beamline_parameters",
566-
return_value=beamline_parameters,
581+
"dodal.beamlines.i03.BEAMLINE_PARAMETERS_PATH",
582+
TEST_BEAMLINE_PARAMETERS,
567583
):
568584
beamstop = i03.beamstop.build(connect_immediately=True, mock=True)
569585

@@ -752,13 +768,19 @@ async def beamsize(aperture_scatterguard: ApertureScatterguard):
752768
return Beamsize(aperture_scatterguard, name="beamsize")
753769

754770

771+
class ConfigFilesForTests(TypedDict):
772+
zoom_params_file: str
773+
oav_config_json: str
774+
display_config: str
775+
776+
755777
@pytest.fixture()
756778
def test_config_files():
757-
return {
758-
"zoom_params_file": "tests/test_data/test_jCameraManZoomLevels.xml",
759-
"oav_config_json": "tests/test_data/test_OAVCentring.json",
760-
"display_config": "tests/test_data/test_display.configuration",
761-
}
779+
return ConfigFilesForTests(
780+
zoom_params_file=TEST_OAV_ZOOM_LEVELS,
781+
oav_config_json=TEST_OAV_CENTRING_JSON,
782+
display_config=TEST_DISPLAY_CONFIG,
783+
)
762784

763785

764786
@pytest.fixture()

tests/system_tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def next_oav_system_test_image():
170170
@pytest.fixture
171171
def oav_for_system_test(test_config_files, next_oav_system_test_image):
172172
parameters = OAVConfigBeamCentre(
173-
test_config_files["zoom_params_file"], test_config_files["display_config"]
173+
test_config_files["zoom_params_file"],
174+
test_config_files["display_config"],
175+
ConfigClient(""),
174176
)
175177
oav = i03.oav.build(connect_immediately=True, mock=True, params=parameters)
176178
set_mock_value(oav.cam.array_size_x, 1024)

tests/system_tests/hyperion/external_interaction/test_load_centre_collect_full_plan.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,14 +1121,6 @@ def grid_detect_for_snapshot_generation():
11211121

11221122

11231123
class TestGenerateSnapshot:
1124-
@pytest.fixture()
1125-
def test_config_files(self):
1126-
return {
1127-
"zoom_params_file": "tests/test_data/test_jCameraManZoomLevels.xml",
1128-
"oav_config_json": "tests/test_data/test_daq_configuration/OAVCentring_hyperion.json",
1129-
"display_config": "tests/test_data/test_daq_configuration/display.configuration",
1130-
}
1131-
11321124
@pytest.mark.system_test
11331125
def test_load_centre_collect_generate_rotation_snapshots(
11341126
self,

tests/test_data/oav/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from os.path import join
2+
from pathlib import Path
3+
4+
TEST_DATA_PATH = Path(__file__).parent
5+
TEST_OAV_CENTRING_JSON = join(TEST_DATA_PATH, "test_OAVCentring.json")
6+
TEST_DISPLAY_CONFIG = join(TEST_DATA_PATH, "test_display.configuration")
7+
TEST_OAV_ZOOM_LEVELS = join(TEST_DATA_PATH, "jCameraManZoomLevels.json")
8+
9+
__all__ = [
10+
"TEST_OAV_CENTRING_JSON",
11+
"TEST_DISPLAY_CONFIG",
12+
"TEST_OAV_ZOOM_LEVELS",
13+
]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"JCameraManSettings": {
3+
"levels": {
4+
"zoomLevel": [
5+
{
6+
"level": "1.0",
7+
"position": "0",
8+
"micronsPerXPixel": "2.87",
9+
"micronsPerYPixel": "2.87"
10+
},
11+
{
12+
"level": "2.5",
13+
"position": "10",
14+
"micronsPerXPixel": "2.31",
15+
"micronsPerYPixel": "2.31"
16+
},
17+
{
18+
"level": "5.0",
19+
"position": "25",
20+
"micronsPerXPixel": "1.58",
21+
"micronsPerYPixel": "1.58"
22+
},
23+
{
24+
"level": "7.5",
25+
"position": "50",
26+
"micronsPerXPixel": "0.806",
27+
"micronsPerYPixel": "0.806"
28+
},
29+
{
30+
"level": "10.0",
31+
"position": "75",
32+
"micronsPerXPixel": "0.438",
33+
"micronsPerYPixel": "0.438"
34+
},
35+
{
36+
"level": "15.0",
37+
"position": "90",
38+
"micronsPerXPixel": "0.302",
39+
"micronsPerYPixel": "0.302"
40+
}
41+
]
42+
},
43+
"tolerance": "1.0"
44+
}
45+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"exposure": 0.075,
3+
"acqPeriod": 0.05,
4+
"gain": 1.0,
5+
"minheight": 70,
6+
"oav": "OAV",
7+
"mxsc_input": "CAM",
8+
"min_callback_time": 0.080,
9+
"close_ksize": 11,
10+
"direction": 0,
11+
"pinTipCentring": {
12+
"zoom": 1.0,
13+
"preprocess": 8,
14+
"preProcessKSize": 21,
15+
"CannyEdgeUpperThreshold": 20.0,
16+
"CannyEdgeLowerThreshold": 5.0,
17+
"brightness": 20,
18+
"max_tip_distance": 300,
19+
"mxsc_input": "proc",
20+
"minheight": 10,
21+
"min_callback_time": 0.15,
22+
"filename": "/dls_sw/prod/R3.14.12.7/support/adPython/2-1-11/adPythonApp/scripts/adPythonMxSampleDetect.py"
23+
},
24+
"loopCentring": {
25+
"zoom": 5.0,
26+
"preprocess": 8,
27+
"preProcessKSize": 21,
28+
"CannyEdgeUpperThreshold": 20.0,
29+
"CannyEdgeLowerThreshold": 5.0,
30+
"brightness": 20,
31+
"filename": "/dls_sw/prod/R3.14.12.7/support/adPython/2-1-11/adPythonApp/scripts/adPythonMxSampleDetect.py",
32+
"max_tip_distance": 300,
33+
"minheight": 10
34+
},
35+
"xrayCentring": {
36+
"zoom": 7.5,
37+
"preprocess": 8,
38+
"preProcessKSize": 31,
39+
"CannyEdgeUpperThreshold": 30.0,
40+
"CannyEdgeLowerThreshold": 5.0,
41+
"close_ksize": 3,
42+
"filename": "/dls_sw/prod/R3.14.12.7/support/adPython/2-1-11/adPythonApp/scripts/adPythonMxSampleDetect.py",
43+
"brightness": 80
44+
},
45+
"rotationAxisAlign": {
46+
"zoom": 10.0,
47+
"preprocess": 8,
48+
"preProcessKSize": 21,
49+
"CannyEdgeUpperThreshold": 20.0,
50+
"CannyEdgeLowerThreshold": 5.0,
51+
"filename": "/dls_sw/prod/R3.14.12.7/support/adPython/2-1-11/adPythonApp/scripts/adPythonMxSampleDetect.py",
52+
"brightness": 100
53+
},
54+
"SmargonOffsets1": {
55+
"zoom": 1.0,
56+
"preprocess": 8,
57+
"preProcessKSize": 21,
58+
"CannyEdgeUpperThreshold": 50.0,
59+
"CannyEdgeLowerThreshold": 5.0,
60+
"brightness": 80
61+
},
62+
"SmargonOffsets2": {
63+
"zoom": 5.0,
64+
"preprocess": 8,
65+
"preProcessKSize": 11,
66+
"CannyEdgeUpperThreshold": 50.0,
67+
"CannyEdgeLowerThreshold": 5.0,
68+
"brightness": 90
69+
}
70+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"zoom_levels": {
3+
"1.0": {
4+
"crosshair_x": 397,
5+
"crosshair_y": 373,
6+
"top_left_x": 383,
7+
"top_left_y": 253,
8+
"bottom_right_x": 410,
9+
"bottom_right_y": 278
10+
},
11+
"2.5": {
12+
"crosshair_x": 413,
13+
"crosshair_y": 368,
14+
"top_left_x": 340,
15+
"top_left_y": 283,
16+
"bottom_right_x": 388,
17+
"bottom_right_y": 322
18+
},
19+
"5.0": {
20+
"crosshair_x": 517,
21+
"crosshair_y": 350,
22+
"top_left_x": 268,
23+
"top_left_y": 326,
24+
"bottom_right_x": 354,
25+
"bottom_right_y": 387
26+
},
27+
"7.5": {
28+
"crosshair_x": 452,
29+
"crosshair_y": 345,
30+
"top_left_x": 248,
31+
"top_left_y": 394,
32+
"bottom_right_x": 377,
33+
"bottom_right_y": 507
34+
},
35+
"10.0": {
36+
"crosshair_x": 502,
37+
"crosshair_y": 350,
38+
"top_left_x": 2,
39+
"top_left_y": 489,
40+
"bottom_right_x": 206,
41+
"bottom_right_y": 630
42+
},
43+
"15.0": {
44+
"crosshair_x": 642,
45+
"crosshair_y": 310,
46+
"top_left_x": 1,
47+
"top_left_y": 601,
48+
"bottom_right_x": 65,
49+
"bottom_right_y": 767
50+
}
51+
},
52+
"required_zoom_levels": null
53+
}

tests/test_data/test_OAVCentring.json

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)