Skip to content

Commit 95cdd8a

Browse files
authored
Agamemnon now specifies separate locations for snapshot images and xrc data (#1783)
* Pass in xrc and snapshot directory from agamemnon
1 parent 1506cb9 commit 95cdd8a

9 files changed

Lines changed: 44 additions & 9 deletions

File tree

src/mx_bluesky/common/parameters/components.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def validate_directories(cls, values):
182182
# Plans using numtracker currently won't work with snapshot directories:
183183
# see https://github.com/DiamondLightSource/mx-bluesky/issues/1527
184184
if values["storage_directory"] != USE_NUMTRACKER:
185+
# TODO don't write to storage here https://github.com/DiamondLightSource/mx-bluesky/issues/1780
185186
os.makedirs(values["storage_directory"], exist_ok=True)
186187

187188
values["snapshot_directory"] = values.get(

src/mx_bluesky/hyperion/blueapi/parameters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class MultiSamplePinTypeParam(BaseModel):
3838

3939
class RobotLoadThenCentreParams(HyperionParam):
4040
storage_directory: str
41+
snapshot_directory: str
4142
file_name: str
4243
transmission_frac: float
4344
exposure_time_s: float
@@ -61,6 +62,7 @@ class MultiRotationScanParams(HyperionParam):
6162
comment: str
6263
file_name: str
6364
storage_directory: str
65+
snapshot_directory: str
6466
exposure_time_s: float
6567
rotation_increment_deg: float
6668
snapshot_omegas_deg: list[float]

src/mx_bluesky/hyperion/external_interaction/agamemnon.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ def _populate_parameters_from_agamemnon(
199199
with_energy_params = _get_withenergy_parameters_from_agamemnon(agamemnon_params)
200200
pin_type = _get_pin_type_from_agamemnon_collect_parameters(agamemnon_params)
201201
collections = agamemnon_params["collection"]
202-
visit_directory, file_name = path.split(agamemnon_params["prefix"])
202+
rotation_storage_directory, rotation_file_name = path.split(
203+
agamemnon_params["prefix"]
204+
)
205+
xrc_storage_directory, xrc_file_name = path.split(agamemnon_params["xrc_prefix"])
206+
snapshot_directory = agamemnon_params["jpegs_dir"]
203207
use_roi_mode = get_hyperion_feature_settings().XRC_USE_ROI_MODE
204208
return [
205209
LoadCentreCollectParams.model_validate(
@@ -215,8 +219,9 @@ def _populate_parameters_from_agamemnon(
215219
},
216220
**with_energy_params,
217221
"robot_load_then_centre": {
218-
"storage_directory": str(visit_directory) + "/xraycentring",
219-
"file_name": file_name,
222+
"snapshot_directory": str(snapshot_directory),
223+
"storage_directory": str(xrc_storage_directory),
224+
"file_name": xrc_file_name,
220225
"pin_type": pin_type,
221226
"omega_starts_deg": [0.0, 90.0],
222227
"chi_start_deg": collection["chi"],
@@ -226,9 +231,10 @@ def _populate_parameters_from_agamemnon(
226231
},
227232
"multi_rotation_scan": {
228233
"comment": collection["comment"],
229-
"storage_directory": str(visit_directory),
234+
"snapshot_directory": str(snapshot_directory),
235+
"storage_directory": str(rotation_storage_directory),
230236
"exposure_time_s": collection["exposure_time"],
231-
"file_name": file_name,
237+
"file_name": rotation_file_name,
232238
"transmission_frac": collection["transmission"],
233239
"rotation_increment_deg": collection["omega_increment"],
234240
"ispyb_experiment_type": collection["experiment_type"],

tests/test_data/agamemnon/example_collect_multipin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
"min": 0.68876
7979
}
8080
},
81-
"prefix": "/dls/tmp/data/year/cm00000-0/auto/test/test_xtal"
81+
"prefix": "/dls/tmp/data/year/cm00000-0/auto/test/test_xtal",
82+
"jpegs_dir": "/dls/tmp/data/year/cm00000-0/jpegs/auto/test/test_xtal",
83+
"xrc_prefix": "/dls/tmp/data/year/cm00000-0/xraycentring/auto/test/test_xtal"
8284
}
8385
}

tests/test_data/agamemnon/example_native.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
}
4848
],
4949
"prefix": "/dls/i03/data/2025/mx34598-77/auto/CBLBA/CBLBA-x00242/CBLBA-x00242",
50+
"jpegs_dir": "/dls/i03/data/2025/mx34598-77/jpegs/auto/CBLBA/CBLBA-x00242",
51+
"xrc_prefix": "/dls/i03/data/2025/mx34598-77/xraycentring/auto/CBLBA/CBLBA-x00242/CBLBA-x00242",
5052
"recipe_limits": {
5153
"distance": {
5254
"max": 800.0,

tests/test_data/parameter_json_files/external_load_centre_collect_params.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"demand_energy_ev": 11100,
88
"robot_load_then_centre": {
99
"storage_directory": "{tmp_data}/123457/xraycentring",
10+
"snapshot_directory": "{tmp_data}/snapshots/123457",
1011
"file_name": "robot_load_centring_file",
1112
"transmission_frac": 1.0,
1213
"exposure_time_s": 0.002,
@@ -21,6 +22,7 @@
2122
"comment": "Hyperion Rotation Scan - ",
2223
"file_name": "protk",
2324
"storage_directory": "{tmp_data}/123457/",
25+
"snapshot_directory": "{tmp_data}/snapshots/123457",
2426
"transmission_frac": 0.05,
2527
"exposure_time_s": 0.004,
2628
"rotation_increment_deg": 0.1,

tests/test_data/parameter_json_files/external_load_centre_collect_params_multipin.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"demand_energy_ev": 11100,
88
"robot_load_then_centre": {
99
"storage_directory": "{tmp_data}/123457/xraycentring",
10+
"snapshot_directory": "{tmp_data}/snapshots/123457",
1011
"file_name": "robot_load_centring_file",
1112
"transmission_frac": 1.0,
1213
"exposure_time_s": 0.002,
@@ -24,6 +25,7 @@
2425
"comment": "Hyperion Rotation Scan - ",
2526
"file_name": "protk",
2627
"storage_directory": "{tmp_data}/123457/",
28+
"snapshot_directory": "{tmp_data}/snapshots/123457",
2729
"transmission_frac": 0.05,
2830
"exposure_time_s": 0.004,
2931
"rotation_increment_deg": 0.1,

tests/unit_tests/hyperion/experiment_plans/test_load_centre_collect_full_plan.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dataclasses
22
from collections.abc import Sequence
3+
from pathlib import Path
34
from typing import Any
45
from unittest.mock import AsyncMock, MagicMock, call, patch
56

@@ -320,6 +321,23 @@ def test_params_with_unexpected_info_in_multi_rotation_scan_rejected(
320321
LoadCentreCollect(**params)
321322

322323

324+
def test_params_with_snapshot_directory_overrides_defaults(tmp_path: Path):
325+
params = raw_params_from_file(
326+
GOOD_TEST_LOAD_CENTRE_COLLECT_MULTI_ROTATION, tmp_path
327+
)
328+
params["robot_load_then_centre"]["snapshot_directory"] = (
329+
"/some/other/path/to/snapshots"
330+
)
331+
params["multi_rotation_scan"]["snapshot_directory"] = "/another/path/to/snapshots"
332+
load_centre_collect = LoadCentreCollect(**params)
333+
assert load_centre_collect.robot_load_then_centre.snapshot_directory == Path(
334+
"/some/other/path/to/snapshots"
335+
)
336+
assert load_centre_collect.multi_rotation_scan.snapshot_directory == Path(
337+
"/another/path/to/snapshots"
338+
)
339+
340+
323341
def test_can_serialize_load_centre_collect_robot_load_params(
324342
load_centre_collect_params,
325343
):

tests/unit_tests/hyperion/external_interaction/test_agamemnon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ def test_create_parameters_from_agamemnon_contains_expected_robot_load_then_cent
288288
assert str(robot_load_params.parameter_model_version) == "6.0.0"
289289
assert (
290290
robot_load_params.storage_directory
291-
== "/dls/i03/data/2025/mx34598-77/auto/CBLBA/CBLBA-x00242/xraycentring"
291+
== "/dls/i03/data/2025/mx34598-77/xraycentring/auto/CBLBA/CBLBA-x00242"
292292
)
293293
assert robot_load_params.file_name == "CBLBA-x00242"
294294
assert robot_load_params.snapshot_directory == PosixPath(
295-
"/dls/i03/data/2025/mx34598-77/auto/CBLBA/CBLBA-x00242/xraycentring/snapshots"
295+
"/dls/i03/data/2025/mx34598-77/jpegs/auto/CBLBA/CBLBA-x00242"
296296
)
297297
assert robot_load_params.use_roi_mode == expected_roi_mode
298298

@@ -332,7 +332,7 @@ def test_create_parameters_from_agamemnon_contains_expected_rotation_data(
332332
)
333333
assert rotation_params.file_name == "CBLBA-x00242"
334334
assert rotation_params.snapshot_directory == PosixPath(
335-
"/dls/i03/data/2025/mx34598-77/auto/CBLBA/CBLBA-x00242/snapshots"
335+
"/dls/i03/data/2025/mx34598-77/jpegs/auto/CBLBA/CBLBA-x00242"
336336
)
337337

338338
individual_scans = list(

0 commit comments

Comments
 (0)