Skip to content

Commit

Permalink
DiamondLightSource/hyperion#1192 simplify callback collections
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Feb 28, 2024
1 parent 4ebe65c commit d68b932
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 42 deletions.
11 changes: 3 additions & 8 deletions src/hyperion/external_interaction/callbacks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,19 @@
from hyperion.parameters.cli import parse_callback_dev_mode_arg
from hyperion.parameters.constants import (
CALLBACK_0MQ_PROXY_PORTS,
DO_FGS,
ROTATION_PLAN_MAIN,
)

LIVENESS_POLL_SECONDS = 1
ERROR_LOG_BUFFER_LINES = 5000


def setup_callbacks():
gridscan_ispyb = GridscanISPyBCallback()
rotation_ispyb = RotationISPyBCallback()
zocalo = ZocaloCallback()
return [
GridscanNexusFileCallback(),
gridscan_ispyb,
ZocaloCallback(DO_FGS),
GridscanISPyBCallback(emit=zocalo),
RotationNexusFileCallback(),
rotation_ispyb,
ZocaloCallback(ROTATION_PLAN_MAIN),
RotationISPyBCallback(emit=zocalo),
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,12 @@
from hyperion.external_interaction.callbacks.zocalo_callback import (
ZocaloCallback,
)
from hyperion.parameters.constants import ROTATION_PLAN_MAIN


@dataclass(frozen=True, order=True)
class RotationCallbackCollection(AbstractPlanCallbackCollection):
"""Groups the callbacks for external interactions for a rotation scan.
Cast to a list to pass it to Bluesky.preprocessors.subs_decorator()."""

nexus_handler: RotationNexusFileCallback
ispyb_handler: RotationISPyBCallback
zocalo_handler: ZocaloCallback

@classmethod
def setup(cls):
nexus_handler = RotationNexusFileCallback()
ispyb_handler = RotationISPyBCallback()
zocalo_handler = ZocaloCallback(ROTATION_PLAN_MAIN)
callback_collection = cls(
nexus_handler=nexus_handler,
ispyb_handler=ispyb_handler,
zocalo_handler=zocalo_handler,
)
return callback_collection
nexus_handler: RotationNexusFileCallback = RotationNexusFileCallback()
ispyb_handler: RotationISPyBCallback = RotationISPyBCallback(emit=ZocaloCallback())
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from hyperion.external_interaction.callbacks.zocalo_callback import (
ZocaloCallback,
)
from hyperion.parameters.constants import DO_FGS


@dataclass(frozen=True, order=True)
Expand All @@ -23,18 +22,5 @@ class XrayCentreCallbackCollection(AbstractPlanCallbackCollection):
connects the Zocalo and ISPyB handlers. Cast to a list to pass it to
Bluesky.preprocessors.subs_decorator()."""

nexus_handler: GridscanNexusFileCallback
ispyb_handler: GridscanISPyBCallback
zocalo_handler: ZocaloCallback

@classmethod
def setup(cls):
nexus_handler = GridscanNexusFileCallback()
ispyb_handler = GridscanISPyBCallback()
zocalo_handler = ZocaloCallback(DO_FGS)
callback_collection = cls(
nexus_handler=nexus_handler,
ispyb_handler=ispyb_handler,
zocalo_handler=zocalo_handler,
)
return callback_collection
nexus_handler: GridscanNexusFileCallback = GridscanNexusFileCallback()
ispyb_handler: GridscanISPyBCallback = GridscanISPyBCallback(emit=ZocaloCallback())
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
)
from hyperion.parameters import external_parameters
from hyperion.parameters.constants import (
DO_FGS,
GRIDSCAN_OUTER_PLAN,
)
from hyperion.parameters.plan_specific.gridscan_internal_params import (
Expand Down Expand Up @@ -745,7 +744,7 @@ def test_kickoff_and_complete_gridscan_triggers_zocalo(
mock_ispyb_handler = MagicMock()
mock_ispyb_handler.ispyb_ids.data_collection_ids = (100, 200)
zocalo_env = "dev_env"
zocalo_callback = ZocaloCallback(DO_FGS)
zocalo_callback = ZocaloCallback()
zocalo_callback.active = True
mock_zocalo_trigger_class.return_value = (mock_zocalo_trigger := MagicMock())
RE.subscribe(zocalo_callback)
Expand Down

0 comments on commit d68b932

Please sign in to comment.