Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
(#1244) update ispyb to deal with synchrotron_mode returning a Synchr…
Browse files Browse the repository at this point in the history
…otronMode
  • Loading branch information
DominicOram committed Apr 19, 2024
1 parent 03f4186 commit 23593b1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, TypeVar

from dodal.devices.synchrotron import SynchrotronMode

from hyperion.external_interaction.callbacks.common.ispyb_mapping import (
populate_data_collection_group,
)
Expand Down Expand Up @@ -96,9 +98,13 @@ def activity_gated_event(self, doc: Event) -> Event:
self._event_driven_data_collection_info.undulator_gap1 = doc["data"][
"undulator_current_gap"
]
self._event_driven_data_collection_info.synchrotron_mode = doc["data"][
"synchrotron-synchrotron_mode"
]
assert isinstance(
synchrotron_mode := doc["data"]["synchrotron-synchrotron_mode"],
SynchrotronMode,
)
self._event_driven_data_collection_info.synchrotron_mode = (
synchrotron_mode.value
)
self._event_driven_data_collection_info.slitgap_horizontal = doc["data"][
"s4_slit_gaps_xgap"
]
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ def fake_fgs_composite(
done_status,
attenuator,
xbpm_feedback,
synchrotron,
aperture_scatterguard,
zocalo,
dcm,
Expand All @@ -555,7 +556,7 @@ def fake_fgs_composite(
s4_slit_gaps=i03.s4_slit_gaps(fake_with_ophyd_sim=True),
smargon=smargon,
undulator=i03.undulator(fake_with_ophyd_sim=True),
synchrotron=i03.synchrotron(fake_with_ophyd_sim=True),
synchrotron=synchrotron,
xbpm_feedback=xbpm_feedback,
zebra=i03.zebra(fake_with_ophyd_sim=True),
zocalo=zocalo,
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/experiment_plans/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from bluesky.utils import Msg
from dodal.devices.fast_grid_scan import FastGridScan
from dodal.devices.oav.oav_detector import OAVConfigParams
from dodal.devices.synchrotron import SynchrotronMode
from dodal.devices.zocalo import ZocaloResults, ZocaloTrigger
from event_model import Event
from ophyd.sim import make_fake_device
Expand Down Expand Up @@ -43,7 +44,7 @@ def make_event_doc(data, descriptor="abc123") -> Event:

BASIC_PRE_SETUP_DOC = {
"undulator_current_gap": 0,
"synchrotron-synchrotron_mode": 0,
"synchrotron-synchrotron_mode": SynchrotronMode.USER,
"s4_slit_gaps_xgap": 0,
"s4_slit_gaps_ygap": 0,
"robot-barcode": "BARCODE",
Expand Down
18 changes: 2 additions & 16 deletions tests/unit_tests/external_interaction/callbacks/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from dodal.devices.synchrotron import SynchrotronMode
from dodal.devices.zocalo.zocalo_results import ZOCALO_READING_PLAN_NAME
from event_model.documents import Event, EventDescriptor, RunStart, RunStop

Expand Down Expand Up @@ -61,21 +62,6 @@ class TestData:
"uid": "2093c941-ded1-42c4-ab74-ea99980fbbfd",
"subplan_name": CONST.PLAN.ROTATION_MAIN,
}
test_rotation_event_document_pre_data_collection: Event = {
"descriptor": "bd45c2e5-2b85-4280-95d7-a9a15800a78b",
"time": 1666604299.828203,
"data": {
"s4_slit_gaps_xgap": 0.1234,
"s4_slit_gaps_ygap": 0.2345,
"synchrotron-synchrotron_mode": "test",
"undulator_current_gap": 1.234,
"robot-barcode": "BARCODE",
},
"timestamps": {"det1": 1666604299.8220396, "det2": 1666604299.8235943},
"seq_num": 1,
"uid": "2093c941-ded1-42c4-ab74-ea99980fbbfd",
"filled": {},
}
test_rotation_event_document_during_data_collection: Event = {
"descriptor": "bd45c2e5-2b85-4280-95d7-a9a15800a78b",
"time": 2666604299.928203,
Expand Down Expand Up @@ -143,7 +129,7 @@ class TestData:
"data": {
"s4_slit_gaps_xgap": 0.1234,
"s4_slit_gaps_ygap": 0.2345,
"synchrotron-synchrotron_mode": "test",
"synchrotron-synchrotron_mode": SynchrotronMode.USER,
"undulator_current_gap": 1.234,
"robot-barcode": "BARCODE",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ def test_activity_gated_event(
callback.activity_gated_descriptor(
TestData.test_descriptor_document_pre_data_collection
)
callback.activity_gated_event(
TestData.test_rotation_event_document_pre_data_collection
)
callback.activity_gated_event(TestData.test_event_document_pre_data_collection)
callback.activity_gated_descriptor(
TestData.test_descriptor_document_during_data_collection
)
Expand All @@ -126,7 +124,7 @@ def test_activity_gated_event(
"id": TEST_DATA_COLLECTION_IDS[0],
"slitgaphorizontal": 0.1234,
"slitgapvertical": 0.2345,
"synchrotronmode": "test",
"synchrotronmode": "User",
"undulatorgap1": 1.234,
"wavelength": 1.1164718451643736,
"transmission": 98,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_activity_gated_event_2d(mock_ispyb_conn):
"id": TEST_DATA_COLLECTION_IDS[0],
"slitgaphorizontal": 0.1234,
"slitgapvertical": 0.2345,
"synchrotronmode": "test",
"synchrotronmode": "User",
"undulatorgap1": 1.234,
"wavelength": 1.1164718451643736,
"transmission": 100,
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_activity_gated_event_3d(mock_ispyb_conn):
"id": TEST_DATA_COLLECTION_IDS[0],
"slitgaphorizontal": 0.1234,
"slitgapvertical": 0.2345,
"synchrotronmode": "test",
"synchrotronmode": "User",
"undulatorgap1": 1.234,
"wavelength": 1.1164718451643736,
"transmission": 100,
Expand Down

0 comments on commit 23593b1

Please sign in to comment.