From f3c8704f4afba817f49f653ab4380dd4be7af93f Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Fri, 22 May 2026 17:17:20 +0200 Subject: [PATCH 1/2] fix(gui_tools): minimal ring progress bar safeguard in order to not interupt any script using it --- .../plugins/flomni/gui_tools.py | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py index 5d03537..274a519 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py @@ -1,8 +1,12 @@ import builtins import time +from bec_lib import bec_logger + # from csaxs_bec.bec_ipython_client.plugins.cSAXS import epics_get, epics_put, fshopen, fshclose +logger = bec_logger.logger + if builtins.__dict__.get("bec") is not None: bec = builtins.__dict__.get("bec") dev = builtins.__dict__.get("dev") @@ -209,18 +213,21 @@ class flomniGuiTools: return True def flomnigui_show_progress(self): - self.flomnigui_show_gui() - if self._flomnigui_is_missing("progressbar"): - self.flomnigui_remove_all_docks() - # Add a new dock with a RingProgressBar widget - self.progressbar = self.gui.flomni.new("RingProgressBar") + try: + self.flomnigui_show_gui() + if self._flomnigui_is_missing("progressbar"): + self.flomnigui_remove_all_docks() + # Add a new dock with a RingProgressBar widget + self.progressbar = self.gui.flomni.new("RingProgressBar") - # Setting multiple rings with different values - self.progressbar.add_ring().set_update("manual") - self.progressbar.add_ring().set_update("manual") - self.progressbar.add_ring().set_update("scan") + # Setting multiple rings with different values + self.progressbar.add_ring().set_update("manual") + self.progressbar.add_ring().set_update("manual") + self.progressbar.add_ring().set_update("scan") - self._flomnigui_update_progress() + self._flomnigui_update_progress() + except Exception as e: + logger.warning(f"Error in flomnigui_show_progress: {e}") def _flomnigui_update_progress(self): """Update the progress ring bar and center label from the current progress state. @@ -231,9 +238,13 @@ class flomniGuiTools: client.get_global_var("tomo_progress") """ - main_progress_ring = self.progressbar.rings[0] - subtomo_progress_ring = self.progressbar.rings[1] - if self.progressbar is not None: + try: + if self.progressbar is None: + logger.warning("flOMNI progress GUI update skipped: progressbar is not available.") + return + + main_progress_ring = self.progressbar.rings[0] + subtomo_progress_ring = self.progressbar.rings[1] progress = self.progress["projection"] / self.progress["total_projections"] * 100 subtomo_progress = ( self.progress["subtomo_projection"] @@ -247,6 +258,7 @@ class flomniGuiTools: start_str = self.progress.get("tomo_start_time") if start_str is not None: import datetime as _dt + start_display = _dt.datetime.fromisoformat(start_str).strftime("%Y-%m-%d %H:%M:%S") else: start_display = "N/A" @@ -255,6 +267,7 @@ class flomniGuiTools: remaining_s = self.progress.get("estimated_remaining_time") if remaining_s is not None and remaining_s >= 0: import datetime as _dt + remaining_s = int(remaining_s) h, rem = divmod(remaining_s, 3600) m, s = divmod(rem, 60) @@ -281,6 +294,8 @@ class flomniGuiTools: f" Est. remaining: {eta_display}" ) self.progressbar.set_center_label(text) + except Exception as exc: + logger.warning(f"flOMNI progress GUI update skipped: {exc}") if __name__ == "__main__": -- 2.52.0 From 29594219c226f6f83604201be0b5890c0df18454 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Fri, 22 May 2026 17:22:43 +0200 Subject: [PATCH 2/2] fix(gui_tools): remove all custom gui timeouts --- .../bec_ipython_client/plugins/flomni/gui_tools.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py index 274a519..a792250 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/gui_tools.py @@ -22,8 +22,6 @@ class flomniGuiToolsError(Exception): class flomniGuiTools: - GUI_RPC_TIMEOUT = 20 - def __init__(self): self.text_box = None self.progressbar = None @@ -43,7 +41,7 @@ class flomniGuiTools: self.flomni_window = self.gui.windows["flomni"] self.gui.flomni.raise_window() else: - self.flomni_window = self.gui.new("flomni", timeout=self.GUI_RPC_TIMEOUT) + self.flomni_window = self.gui.new("flomni") time.sleep(1) def flomnigui_stop_gui(self): @@ -56,9 +54,7 @@ class flomniGuiTools: self.flomnigui_show_gui() if self._flomnigui_is_missing("xeyegui"): self.flomnigui_remove_all_docks() - self.xeyegui = self.gui.flomni.new( - "XRayEye", object_name="xrayeye", timeout=self.GUI_RPC_TIMEOUT - ) + self.xeyegui = self.gui.flomni.new("XRayEye", object_name="xrayeye") # start live if not dev.cam_xeye.live_mode_enabled.get(): dev.cam_xeye.live_mode_enabled.put(True) @@ -68,9 +64,7 @@ class flomniGuiTools: self.flomnigui_show_gui() if self._flomnigui_is_missing("xeyegui"): self.flomnigui_remove_all_docks() - self.xeyegui = self.gui.flomni.new( - "XRayEye", object_name="xrayeye", timeout=self.GUI_RPC_TIMEOUT - ) + self.xeyegui = self.gui.flomni.new("XRayEye", object_name="xrayeye") self.xeyegui.switch_tab("fit") def _flomnigui_check_attribute_not_exists(self, attribute_name): @@ -128,7 +122,7 @@ class flomniGuiTools: # dev.cam_flomni_gripper.stop_live_mode() # dev.cam_xeye.live_mode = False if hasattr(self.gui, "flomni"): - self.gui.flomni.delete_all(timeout=self.GUI_RPC_TIMEOUT) + self.gui.flomni.delete_all() self.progressbar = None self.text_box = None self.xeyegui = None -- 2.52.0