From 2b688c9f8d6931aa66fcff949721ea75023628b5 Mon Sep 17 00:00:00 2001 From: Phantominumm Date: Tue, 18 Aug 2026 09:52:54 +0200 Subject: [PATCH] Run controller commands in BLISS session via BlissProxy when available - Add _bliss_session_call(), a helper that calls a function by name in the BLISS session via BlissProxy and blocks for the result - init() now prefers this session call over getattr(controller, key) when bliss_proxy is configured, falling back to the controller object otherwise - Log a warning instead of silently skipping when a controller command can't be resolved --- .../ESRF/ESRFBeamlineActions.py | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/mxcubecore/HardwareObjects/ESRF/ESRFBeamlineActions.py b/mxcubecore/HardwareObjects/ESRF/ESRFBeamlineActions.py index c28ec5e508..ceb93f602f 100644 --- a/mxcubecore/HardwareObjects/ESRF/ESRFBeamlineActions.py +++ b/mxcubecore/HardwareObjects/ESRF/ESRFBeamlineActions.py @@ -37,6 +37,7 @@ from ast import literal_eval +from mxcubecore import HardwareRepository as HWR from mxcubecore.HardwareObjects.BeamlineActions import ( BeamlineActions, ControllerCommand, @@ -55,6 +56,15 @@ def __init__(self, *args): self.ctrl_list = [] self.hwobj_list = [] + @staticmethod + def _bliss_session_call(function_name): + """Build a callable that runs 'function_name' in the BLISS session + via the BlissProxy REST client and blocks for the result. + """ + return lambda *args, **kwargs: HWR.beamline.bliss_proxy.session.call( + function_name, *args, **kwargs + ).get() + def init(self): """Initialise the controller commands and the actuator object to be used. @@ -63,13 +73,23 @@ def init(self): if ctrl_cmds: controller = self.get_object_by_role("controller") + bliss_proxy = getattr(HWR.beamline, "bliss_proxy", None) for key, name in ctrl_cmds.items(): - try: - action = getattr(controller, key) + if bliss_proxy is not None: + # Prefer running the command in the BLISS session; + action = self._bliss_session_call(key) + elif controller is not None: + try: + action = getattr(controller, key) + except AttributeError: + action = None + else: + action = None + + if action is not None: self.ctrl_list.append(ControllerCommand(name, action)) - except AttributeError: - # self.log.exception("") - pass + else: + self.log.warning(f"Could not resolve controller command '{key}'") hwobj_cmd_roles = self.get_property("hwobj_command_roles") if hwobj_cmd_roles: