mx-bluesky 1.2.0__py3-none-any.whl → 1.4.1a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky/__init__.py +8 -3
- mx_bluesky/__main__.py +12 -7
- mx_bluesky/_version.py +2 -2
- mx_bluesky/beamlines/i04/callbacks/murko_callback.py +14 -4
- mx_bluesky/beamlines/i04/thawing_plan.py +49 -11
- mx_bluesky/beamlines/i24/serial/__init__.py +3 -0
- mx_bluesky/beamlines/i24/serial/dcid.py +19 -21
- mx_bluesky/beamlines/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +69 -91
- mx_bluesky/beamlines/i24/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +2 -5
- mx_bluesky/beamlines/i24/serial/fixed_target/ft_utils.py +0 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +111 -143
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +141 -222
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +7 -216
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_moveonclick.py +18 -17
- mx_bluesky/beamlines/i24/serial/log.py +58 -49
- mx_bluesky/beamlines/i24/serial/parameters/constants.py +0 -1
- mx_bluesky/beamlines/i24/serial/parameters/fixed_target/cs/cs_maker.json +3 -3
- mx_bluesky/beamlines/i24/serial/run_extruder.sh +30 -5
- mx_bluesky/beamlines/i24/serial/run_fixed_target.sh +30 -5
- mx_bluesky/beamlines/i24/serial/run_serial.py +24 -8
- mx_bluesky/beamlines/i24/serial/setup_beamline/ca.py +0 -2
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_beamline.py +79 -81
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_detector.py +9 -20
- mx_bluesky/beamlines/i24/serial/setup_beamline/setup_zebra_plans.py +26 -28
- mx_bluesky/beamlines/i24/serial/write_nexus.py +11 -11
- mx_bluesky/common/__init__.py +0 -0
- mx_bluesky/common/device_setup_plans/read_hardware_for_setup.py +14 -0
- mx_bluesky/common/external_interaction/config_server.py +46 -0
- mx_bluesky/common/parameters/components.py +258 -0
- mx_bluesky/common/parameters/constants.py +138 -0
- mx_bluesky/common/parameters/gridscan.py +94 -0
- mx_bluesky/common/parameters/robot_load.py +16 -0
- mx_bluesky/common/plans/__init__.py +1 -0
- mx_bluesky/common/plans/do_fgs.py +121 -0
- mx_bluesky/common/utils/log.py +118 -0
- mx_bluesky/{hyperion → common/utils}/tracing.py +2 -2
- mx_bluesky/hyperion/__main__.py +13 -10
- mx_bluesky/hyperion/device_setup_plans/dcm_pitch_roll_mirror_adjuster.py +31 -26
- mx_bluesky/hyperion/device_setup_plans/read_hardware_for_setup.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_oav.py +6 -12
- mx_bluesky/hyperion/device_setup_plans/setup_panda.py +5 -6
- mx_bluesky/hyperion/device_setup_plans/setup_zebra.py +49 -18
- mx_bluesky/hyperion/device_setup_plans/smargon.py +6 -6
- mx_bluesky/hyperion/device_setup_plans/utils.py +2 -2
- mx_bluesky/hyperion/device_setup_plans/xbpm_feedback.py +4 -4
- mx_bluesky/hyperion/experiment_plans/__init__.py +4 -0
- mx_bluesky/hyperion/experiment_plans/change_aperture_then_move_plan.py +83 -0
- mx_bluesky/hyperion/experiment_plans/common/xrc_result.py +47 -0
- mx_bluesky/hyperion/experiment_plans/experiment_registry.py +9 -9
- mx_bluesky/hyperion/experiment_plans/flyscan_xray_centre_plan.py +145 -161
- mx_bluesky/hyperion/experiment_plans/grid_detect_then_xray_centre_plan.py +56 -22
- mx_bluesky/hyperion/experiment_plans/load_centre_collect_full_plan.py +52 -10
- mx_bluesky/hyperion/experiment_plans/oav_grid_detection_plan.py +21 -20
- mx_bluesky/hyperion/experiment_plans/oav_snapshot_plan.py +11 -14
- mx_bluesky/hyperion/experiment_plans/optimise_attenuation_plan.py +2 -2
- mx_bluesky/hyperion/experiment_plans/pin_centre_then_xray_centre_plan.py +40 -21
- mx_bluesky/hyperion/experiment_plans/pin_tip_centring_plan.py +19 -19
- mx_bluesky/hyperion/experiment_plans/robot_load_and_change_energy.py +21 -21
- mx_bluesky/hyperion/experiment_plans/robot_load_then_centre_plan.py +51 -13
- mx_bluesky/hyperion/experiment_plans/rotation_scan_plan.py +24 -7
- mx_bluesky/hyperion/experiment_plans/set_energy_plan.py +5 -6
- mx_bluesky/hyperion/external_interaction/callbacks/__main__.py +1 -2
- mx_bluesky/hyperion/external_interaction/callbacks/common/abstract_event.py +66 -0
- mx_bluesky/hyperion/external_interaction/callbacks/common/ispyb_mapping.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/grid_detection_callback.py +30 -25
- mx_bluesky/hyperion/external_interaction/callbacks/ispyb_callback_base.py +29 -12
- mx_bluesky/hyperion/external_interaction/callbacks/log_uid_tag_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/robot_load/ispyb_callback.py +1 -1
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/ispyb_callback.py +7 -4
- mx_bluesky/hyperion/external_interaction/callbacks/rotation/nexus_callback.py +5 -3
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/ispyb_callback.py +28 -20
- mx_bluesky/hyperion/external_interaction/callbacks/xray_centre/nexus_callback.py +5 -4
- mx_bluesky/hyperion/external_interaction/config_server.py +11 -28
- mx_bluesky/hyperion/external_interaction/ispyb/exp_eye_store.py +1 -1
- mx_bluesky/hyperion/external_interaction/ispyb/ispyb_store.py +1 -1
- mx_bluesky/hyperion/external_interaction/nexus/nexus_utils.py +2 -2
- mx_bluesky/hyperion/external_interaction/nexus/write_nexus.py +1 -1
- mx_bluesky/hyperion/log.py +0 -84
- mx_bluesky/hyperion/parameters/components.py +4 -251
- mx_bluesky/hyperion/parameters/constants.py +22 -119
- mx_bluesky/hyperion/parameters/gridscan.py +35 -74
- mx_bluesky/hyperion/parameters/load_centre_collect.py +16 -11
- mx_bluesky/hyperion/parameters/rotation.py +23 -10
- mx_bluesky/hyperion/utils/utils.py +17 -0
- mx_bluesky/hyperion/utils/validation.py +5 -6
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/METADATA +36 -33
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/RECORD +91 -81
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/WHEEL +1 -1
- mx_bluesky/beamlines/i24/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +0 -161
- mx_bluesky/example.py +0 -19
- mx_bluesky/hyperion/parameters/robot_load.py +0 -16
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/LICENSE +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/entry_points.txt +0 -0
- {mx_bluesky-1.2.0.dist-info → mx_bluesky-1.4.1a0.dist-info}/top_level.txt +0 -0
mx_bluesky/__init__.py
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"""Top level API.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
.. data:: __version__
|
|
4
|
+
:type: str
|
|
5
|
+
|
|
6
|
+
Version number as calculated by https://github.com/pypa/setuptools_scm
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from ._version import __version__
|
|
5
10
|
|
|
6
11
|
__all__ = ["__version__"]
|
mx_bluesky/__main__.py
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
"""Interface for ``python -m mx_bluesky``."""
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from argparse import ArgumentParser
|
|
4
|
+
from collections.abc import Sequence
|
|
4
5
|
|
|
5
6
|
from . import __version__
|
|
6
7
|
|
|
7
8
|
__all__ = ["main"]
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
def main(args=None):
|
|
11
|
+
def main(args: Sequence[str] | None = None) -> None:
|
|
12
|
+
"""Argument parser for the CLI."""
|
|
11
13
|
parser = ArgumentParser()
|
|
12
|
-
parser.add_argument(
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-v",
|
|
16
|
+
"--version",
|
|
17
|
+
action="version",
|
|
18
|
+
version=__version__,
|
|
19
|
+
)
|
|
20
|
+
parser.parse_args(args)
|
|
15
21
|
|
|
16
22
|
|
|
17
|
-
# test with: python -m mx_bluesky
|
|
18
23
|
if __name__ == "__main__":
|
|
19
24
|
main()
|
mx_bluesky/_version.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import json
|
|
3
|
+
from datetime import timedelta
|
|
3
4
|
|
|
4
5
|
from bluesky.callbacks import CallbackBase
|
|
5
6
|
from dodal.log import LOGGER
|
|
6
|
-
from event_model.documents import Event, RunStart
|
|
7
|
+
from event_model.documents import Event, RunStart, RunStop
|
|
7
8
|
from redis import StrictRedis
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class MurkoCallback(CallbackBase):
|
|
12
|
+
DATA_EXPIRY_DAYS = 7
|
|
13
|
+
|
|
11
14
|
def __init__(self, redis_host: str, redis_password: str, redis_db: int = 0):
|
|
12
15
|
self.redis_client = StrictRedis(
|
|
13
16
|
host=redis_host, password=redis_password, db=redis_db
|
|
@@ -15,15 +18,17 @@ class MurkoCallback(CallbackBase):
|
|
|
15
18
|
self.last_uuid = None
|
|
16
19
|
|
|
17
20
|
def start(self, doc: RunStart) -> RunStart | None:
|
|
21
|
+
self.sample_id = doc.get("sample_id")
|
|
18
22
|
self.murko_metadata = {
|
|
19
23
|
"zoom_percentage": doc.get("zoom_percentage"),
|
|
20
24
|
"microns_per_x_pixel": doc.get("microns_per_x_pixel"),
|
|
21
25
|
"microns_per_y_pixel": doc.get("microns_per_y_pixel"),
|
|
22
26
|
"beam_centre_i": doc.get("beam_centre_i"),
|
|
23
27
|
"beam_centre_j": doc.get("beam_centre_j"),
|
|
24
|
-
"sample_id":
|
|
28
|
+
"sample_id": self.sample_id,
|
|
25
29
|
}
|
|
26
30
|
self.last_uuid = None
|
|
31
|
+
LOGGER.info(f"Starting to stream metadata to murko under {self.sample_id}")
|
|
27
32
|
return doc
|
|
28
33
|
|
|
29
34
|
def event(self, doc: Event) -> Event:
|
|
@@ -40,6 +45,11 @@ class MurkoCallback(CallbackBase):
|
|
|
40
45
|
metadata["uuid"] = uuid
|
|
41
46
|
|
|
42
47
|
# Send metadata to REDIS and trigger murko
|
|
43
|
-
|
|
48
|
+
redis_key = f"murko:{metadata['sample_id']}:metadata"
|
|
49
|
+
self.redis_client.hset(redis_key, uuid, json.dumps(metadata))
|
|
50
|
+
self.redis_client.expire(redis_key, timedelta(days=self.DATA_EXPIRY_DAYS))
|
|
44
51
|
self.redis_client.publish("murko", json.dumps(metadata))
|
|
45
|
-
|
|
52
|
+
|
|
53
|
+
def stop(self, doc: RunStop) -> RunStop | None:
|
|
54
|
+
LOGGER.info(f"Finished streaming {self.sample_id} to murko")
|
|
55
|
+
return doc
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
|
|
1
3
|
import bluesky.plan_stubs as bps
|
|
2
4
|
import bluesky.preprocessors as bpp
|
|
3
5
|
from bluesky.preprocessors import run_decorator, subs_decorator
|
|
4
|
-
from
|
|
6
|
+
from bluesky.utils import MsgGenerator
|
|
5
7
|
from dodal.beamlines.i04 import MURKO_REDIS_DB, REDIS_HOST, REDIS_PASSWORD
|
|
6
8
|
from dodal.common import inject
|
|
7
9
|
from dodal.devices.oav.oav_detector import OAV
|
|
8
|
-
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder
|
|
10
|
+
from dodal.devices.oav.oav_to_redis_forwarder import OAVToRedisForwarder, Source
|
|
9
11
|
from dodal.devices.robot import BartRobot
|
|
10
12
|
from dodal.devices.smargon import Smargon
|
|
11
13
|
from dodal.devices.thawer import Thawer, ThawerStates
|
|
@@ -22,31 +24,62 @@ def thaw_and_stream_to_redis(
|
|
|
22
24
|
oav: OAV = inject("oav"),
|
|
23
25
|
oav_to_redis_forwarder: OAVToRedisForwarder = inject("oav_to_redis_forwarder"),
|
|
24
26
|
) -> MsgGenerator:
|
|
25
|
-
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage)
|
|
27
|
+
zoom_percentage = yield from bps.rd(oav.zoom_controller.percentage) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
26
28
|
sample_id = yield from bps.rd(robot.sample_id)
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
yield from bps.
|
|
30
|
+
sample_id = int(sample_id)
|
|
31
|
+
zoom_level_before_thawing = yield from bps.rd(oav.zoom_controller.level) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
32
|
+
|
|
33
|
+
yield from bps.mv(oav.zoom_controller.level, "1.0x") # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
34
|
+
|
|
35
|
+
def switch_forwarder_to_ROI() -> MsgGenerator:
|
|
36
|
+
yield from bps.complete(oav_to_redis_forwarder, wait=True)
|
|
37
|
+
yield from bps.mv(
|
|
38
|
+
# See: https://github.com/bluesky/bluesky/issues/1809
|
|
39
|
+
oav_to_redis_forwarder.selected_source, # type: ignore
|
|
40
|
+
Source.ROI.value, # type: ignore
|
|
41
|
+
)
|
|
42
|
+
yield from bps.kickoff(oav_to_redis_forwarder, wait=True)
|
|
43
|
+
|
|
44
|
+
microns_per_pixel_x = yield from bps.rd(oav.microns_per_pixel_x)
|
|
45
|
+
microns_per_pixel_y = yield from bps.rd(oav.microns_per_pixel_y)
|
|
46
|
+
beam_centre_i = yield from bps.rd(oav.beam_centre_i)
|
|
47
|
+
beam_centre_j = yield from bps.rd(oav.beam_centre_j)
|
|
30
48
|
|
|
31
49
|
@subs_decorator(MurkoCallback(REDIS_HOST, REDIS_PASSWORD, MURKO_REDIS_DB))
|
|
32
50
|
@run_decorator(
|
|
33
51
|
md={
|
|
34
|
-
"microns_per_x_pixel":
|
|
35
|
-
"microns_per_y_pixel":
|
|
36
|
-
"beam_centre_i":
|
|
37
|
-
"beam_centre_j":
|
|
52
|
+
"microns_per_x_pixel": microns_per_pixel_x,
|
|
53
|
+
"microns_per_y_pixel": microns_per_pixel_y,
|
|
54
|
+
"beam_centre_i": beam_centre_i,
|
|
55
|
+
"beam_centre_j": beam_centre_j,
|
|
38
56
|
"zoom_percentage": zoom_percentage,
|
|
39
57
|
"sample_id": sample_id,
|
|
40
58
|
}
|
|
41
59
|
)
|
|
42
60
|
def _thaw_and_stream_to_redis():
|
|
61
|
+
yield from bps.mv(
|
|
62
|
+
oav_to_redis_forwarder.sample_id, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
63
|
+
sample_id, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
64
|
+
oav_to_redis_forwarder.selected_source, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
65
|
+
Source.FULL_SCREEN.value, # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
66
|
+
)
|
|
67
|
+
|
|
43
68
|
yield from bps.kickoff(oav_to_redis_forwarder, wait=True)
|
|
44
69
|
yield from bps.monitor(smargon.omega.user_readback, name="smargon")
|
|
45
70
|
yield from bps.monitor(oav_to_redis_forwarder.uuid, name="oav")
|
|
46
|
-
yield from thaw(
|
|
71
|
+
yield from thaw(
|
|
72
|
+
time_to_thaw, rotation, thawer, smargon, switch_forwarder_to_ROI
|
|
73
|
+
)
|
|
47
74
|
yield from bps.complete(oav_to_redis_forwarder)
|
|
48
75
|
|
|
49
|
-
|
|
76
|
+
def cleanup():
|
|
77
|
+
yield from bps.mv(oav.zoom_controller.level, zoom_level_before_thawing) # type: ignore # See: https://github.com/bluesky/bluesky/issues/1809
|
|
78
|
+
|
|
79
|
+
yield from bpp.contingency_wrapper(
|
|
80
|
+
_thaw_and_stream_to_redis(),
|
|
81
|
+
final_plan=cleanup,
|
|
82
|
+
)
|
|
50
83
|
|
|
51
84
|
|
|
52
85
|
def thaw(
|
|
@@ -54,6 +87,7 @@ def thaw(
|
|
|
54
87
|
rotation: float = 360,
|
|
55
88
|
thawer: Thawer = inject("thawer"),
|
|
56
89
|
smargon: Smargon = inject("smargon"),
|
|
90
|
+
plan_between_rotations: Callable[[], MsgGenerator] | None = None,
|
|
57
91
|
) -> MsgGenerator:
|
|
58
92
|
"""Rotates the sample and thaws it at the same time.
|
|
59
93
|
|
|
@@ -64,6 +98,8 @@ def thaw(
|
|
|
64
98
|
thawer (Thawer, optional): The thawing device. Defaults to inject("thawer").
|
|
65
99
|
smargon (Smargon, optional): The smargon used to rotate.
|
|
66
100
|
Defaults to inject("smargon")
|
|
101
|
+
plan_between_rotations (MsgGenerator, optional): A plan to run between rotations
|
|
102
|
+
of the smargon. Defaults to no plan.
|
|
67
103
|
"""
|
|
68
104
|
inital_velocity = yield from bps.rd(smargon.omega.velocity)
|
|
69
105
|
new_velocity = abs(rotation / time_to_thaw) * 2.0
|
|
@@ -72,6 +108,8 @@ def thaw(
|
|
|
72
108
|
yield from bps.abs_set(smargon.omega.velocity, new_velocity, wait=True)
|
|
73
109
|
yield from bps.abs_set(thawer.control, ThawerStates.ON, wait=True)
|
|
74
110
|
yield from bps.rel_set(smargon.omega, rotation, wait=True)
|
|
111
|
+
if plan_between_rotations:
|
|
112
|
+
yield from plan_between_rotations()
|
|
75
113
|
yield from bps.rel_set(smargon.omega, -rotation, wait=True)
|
|
76
114
|
|
|
77
115
|
def cleanup():
|
|
@@ -22,6 +22,7 @@ from .fixed_target.i24ssx_Chip_Manager_py3v1 import (
|
|
|
22
22
|
upload_parameters,
|
|
23
23
|
write_parameter_file,
|
|
24
24
|
)
|
|
25
|
+
from .log import clean_up_log_config_at_end, setup_collection_logs
|
|
25
26
|
from .setup_beamline.setup_detector import setup_detector_stage
|
|
26
27
|
|
|
27
28
|
__all__ = [
|
|
@@ -46,4 +47,6 @@ __all__ = [
|
|
|
46
47
|
"save_screen_map",
|
|
47
48
|
"upload_parameters",
|
|
48
49
|
"write_parameter_file",
|
|
50
|
+
"setup_collection_logs",
|
|
51
|
+
"clean_up_log_config_at_end",
|
|
49
52
|
]
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import json
|
|
3
|
-
import logging
|
|
4
3
|
import math
|
|
5
4
|
import os
|
|
6
5
|
import re
|
|
@@ -10,6 +9,7 @@ from functools import lru_cache
|
|
|
10
9
|
|
|
11
10
|
import requests
|
|
12
11
|
|
|
12
|
+
from mx_bluesky.beamlines.i24.serial.log import SSX_LOGGER
|
|
13
13
|
from mx_bluesky.beamlines.i24.serial.parameters import SSXType
|
|
14
14
|
from mx_bluesky.beamlines.i24.serial.setup_beamline import (
|
|
15
15
|
Detector,
|
|
@@ -25,8 +25,6 @@ try:
|
|
|
25
25
|
except ImportError:
|
|
26
26
|
pass
|
|
27
27
|
|
|
28
|
-
logger = logging.getLogger("I24ssx.DCID")
|
|
29
|
-
|
|
30
28
|
|
|
31
29
|
# Collection start/end script to kick off analysis
|
|
32
30
|
COLLECTION_START_SCRIPT = "/dls_sw/i24/scripts/RunAtStartOfCollect-i24-ssx.sh"
|
|
@@ -41,7 +39,7 @@ CREDENTIALS_LOCATION = "/scratch/ssx_dcserver.key"
|
|
|
41
39
|
def get_auth_header() -> dict:
|
|
42
40
|
"""Read the credentials file and build the Authorisation header"""
|
|
43
41
|
if not os.path.isfile(CREDENTIALS_LOCATION):
|
|
44
|
-
|
|
42
|
+
SSX_LOGGER.warning(
|
|
45
43
|
"Could not read %s; attempting to proceed without credentials",
|
|
46
44
|
CREDENTIALS_LOCATION,
|
|
47
45
|
)
|
|
@@ -205,12 +203,12 @@ class DCID:
|
|
|
205
203
|
|
|
206
204
|
# Log what we are doing here
|
|
207
205
|
try:
|
|
208
|
-
|
|
206
|
+
SSX_LOGGER.info(
|
|
209
207
|
"BRIDGE: POST /dc --data %s",
|
|
210
208
|
repr(json.dumps(data)),
|
|
211
209
|
)
|
|
212
210
|
except Exception:
|
|
213
|
-
|
|
211
|
+
SSX_LOGGER.info(
|
|
214
212
|
"Caught exception converting data to JSON. Data:\n%s\nVERBOSE:\n%s",
|
|
215
213
|
str({k: type(v) for k, v in data.items()}),
|
|
216
214
|
)
|
|
@@ -224,20 +222,20 @@ class DCID:
|
|
|
224
222
|
)
|
|
225
223
|
resp.raise_for_status()
|
|
226
224
|
self.dcid = resp.json()["dataCollectionId"]
|
|
227
|
-
|
|
225
|
+
SSX_LOGGER.info("Generated DCID %s", self.dcid)
|
|
228
226
|
except requests.HTTPError as e:
|
|
229
227
|
self.error = True
|
|
230
|
-
|
|
228
|
+
SSX_LOGGER.error(
|
|
231
229
|
"DCID generation Failed; Reason from server: %s", e.response.text
|
|
232
230
|
)
|
|
233
231
|
if self.emit_errors:
|
|
234
232
|
raise
|
|
235
|
-
|
|
233
|
+
SSX_LOGGER.exception("Error generating DCID: %s", e)
|
|
236
234
|
except Exception as e:
|
|
237
235
|
self.error = True
|
|
238
236
|
if self.emit_errors:
|
|
239
237
|
raise
|
|
240
|
-
|
|
238
|
+
SSX_LOGGER.exception("Error generating DCID: %s", e)
|
|
241
239
|
|
|
242
240
|
def __int__(self):
|
|
243
241
|
return self.dcid
|
|
@@ -248,13 +246,13 @@ class DCID:
|
|
|
248
246
|
return None
|
|
249
247
|
try:
|
|
250
248
|
command = [COLLECTION_START_SCRIPT, str(self.dcid)]
|
|
251
|
-
|
|
249
|
+
SSX_LOGGER.info("Running %s", " ".join(command))
|
|
252
250
|
subprocess.Popen(command)
|
|
253
251
|
except Exception as e:
|
|
254
252
|
self.error = True
|
|
255
253
|
if self.emit_errors:
|
|
256
254
|
raise
|
|
257
|
-
|
|
255
|
+
SSX_LOGGER.warning("Error starting start of collect script: %s", e)
|
|
258
256
|
|
|
259
257
|
def notify_end(self):
|
|
260
258
|
"""Send notifications that the collection has now ended"""
|
|
@@ -262,13 +260,13 @@ class DCID:
|
|
|
262
260
|
return
|
|
263
261
|
try:
|
|
264
262
|
command = [COLLECTION_END_SCRIPT, str(self.dcid)]
|
|
265
|
-
|
|
263
|
+
SSX_LOGGER.info("Running %s", " ".join(command))
|
|
266
264
|
subprocess.Popen(command)
|
|
267
265
|
except Exception as e:
|
|
268
266
|
self.error = True
|
|
269
267
|
if self.emit_errors:
|
|
270
268
|
raise
|
|
271
|
-
|
|
269
|
+
SSX_LOGGER.warning("Error running end of collect notification: %s", e)
|
|
272
270
|
|
|
273
271
|
def collection_complete(
|
|
274
272
|
self, end_time: str | datetime.datetime | None = None, aborted: bool = False
|
|
@@ -285,7 +283,7 @@ class DCID:
|
|
|
285
283
|
# end_time might be a string from time.ctime
|
|
286
284
|
if isinstance(end_time, str):
|
|
287
285
|
end_time = datetime.datetime.strptime(end_time, "%a %b %d %H:%M:%S %Y")
|
|
288
|
-
|
|
286
|
+
SSX_LOGGER.debug("Parsed end time: %s", end_time)
|
|
289
287
|
|
|
290
288
|
if not end_time:
|
|
291
289
|
end_time = datetime.datetime.now().astimezone()
|
|
@@ -302,13 +300,13 @@ class DCID:
|
|
|
302
300
|
if self.dcid is None:
|
|
303
301
|
# Print what we would have sent. This means that if something is failing,
|
|
304
302
|
# we still have the data to upload in the log files.
|
|
305
|
-
|
|
303
|
+
SSX_LOGGER.info(
|
|
306
304
|
'BRIDGE: No DCID but Would PATCH "/dc/XXXX" --data=%s',
|
|
307
305
|
repr(json.dumps(data)),
|
|
308
306
|
)
|
|
309
307
|
return
|
|
310
308
|
|
|
311
|
-
|
|
309
|
+
SSX_LOGGER.info(
|
|
312
310
|
'BRIDGE: PATCH "/dc/%s" --data=%s', self.dcid, repr(json.dumps(data))
|
|
313
311
|
)
|
|
314
312
|
response = requests.patch(
|
|
@@ -318,7 +316,7 @@ class DCID:
|
|
|
318
316
|
headers=get_auth_header(),
|
|
319
317
|
)
|
|
320
318
|
response.raise_for_status()
|
|
321
|
-
|
|
319
|
+
SSX_LOGGER.info("Successfully updated end time for DCID %d", self.dcid)
|
|
322
320
|
except Exception as e:
|
|
323
321
|
resp_obj = getattr(e, "response", None)
|
|
324
322
|
try:
|
|
@@ -333,7 +331,7 @@ class DCID:
|
|
|
333
331
|
self.error = True
|
|
334
332
|
if self.emit_errors:
|
|
335
333
|
raise
|
|
336
|
-
|
|
334
|
+
SSX_LOGGER.warning("Error completing DCID: %s (%s)", e, resp_str)
|
|
337
335
|
|
|
338
336
|
|
|
339
337
|
def get_pilatus_filename_template_from_pvs() -> str:
|
|
@@ -385,9 +383,9 @@ def get_beamsize() -> tuple[float | None, float | None]:
|
|
|
385
383
|
h_mode = caget("BL24I-OP-MFM-01:G1:TARGETAPPLY")
|
|
386
384
|
# Validate these and note an error otherwise
|
|
387
385
|
if not v_mode.startswith("VMFM") or v_mode[4:] not in focus_modes:
|
|
388
|
-
|
|
386
|
+
SSX_LOGGER.error("Unrecognised vertical beam mode %s", v_mode)
|
|
389
387
|
if not h_mode.startswith("HMFM") or h_mode[4:] not in focus_modes:
|
|
390
|
-
|
|
388
|
+
SSX_LOGGER.error("Unrecognised horizontal beam mode %s", h_mode)
|
|
391
389
|
_, h, _ = focus_modes.get(h_mode[4:], (None, None, None))
|
|
392
390
|
_, _, v = focus_modes.get(v_mode[4:], (None, None, None))
|
|
393
391
|
|