diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md b/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md index 4e69ef53..d210c3ba 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md +++ b/csaxs_bec/bec_ipython_client/plugins/omny/AI_docs/OPEN_ISSUES.md @@ -190,14 +190,25 @@ data (`self.progress`, global-var-backed since Phase 1): flomni-only. `_describe_active_hook()`/`_active_hook_source()` needed no porting: already provided by `TomoQueueMixin` since Phase 1. +**Follow-up bug found while porting this**: Mirko reported that on macOS, the progress window +appeared to close and reopen on every single projection during a scan -- "highly annoying". +`_tomo_scan_at_angle()` was calling `self.omnygui_show_progress()` (the full show-window-and-raise- +to-front routine) once per angle, not just `_print_progress()`/`_omnygui_update_progress()` (values +and text only). flomni's own `_tomo_scan_at_angle()` never re-raises the window per angle either -- +it only ever calls `_print_progress()`, which internally calls `_flomnigui_update_progress()` at +its own end. Fixed by mirroring that structure exactly: `_print_progress()` now calls +`self._omnygui_update_progress()` itself, and the separate per-angle `omnygui_show_progress()` call +was removed from `_tomo_scan_at_angle()` -- the window is still shown/raised exactly once, by +`tomo_scan()`'s own unconditional call at scan start. + **Not ported**: flomni's separate `_log_tomogram_timing()`/persistent timing-statistics-log subsystem (writes a JSON record per tomogram to `~/data/raw/logs/timing_statistics`, backing `scilog_last_ptycho_scans()`/a timing overview command) -- Mirko asked specifically about the *printed* summary and the ring count, not this larger, separate logging feature. Flag if wanted. -Test coverage: 9 new tests (`test_omny_tomo_scan.py`: idle-time-from-gap, no-idle-time-within- -cadence, end-of-scan summary lines; `test_omny_gui_tools.py`: three-ring creation, center-label -text with/without an active hook). Full suite: 731 passed. +Test coverage: 10 new tests (`test_omny_tomo_scan.py`: idle-time-from-gap, no-idle-time-within- +cadence, end-of-scan summary lines, window not re-raised per angle; `test_omny_gui_tools.py`: +three-ring creation, center-label text with/without an active hook). Full suite: 732 passed. ## cam_xeye device (simulated only, real hardware config still needed) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index 7fdc04ba..fbc4f402 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -1256,8 +1256,16 @@ class OMNY( ) self.progress["heartbeat"] = now.isoformat() print(f"Starting OMNY scan for angle {angle} in subtomo {subtomo_number}") + # _print_progress() refreshes the progress GUI itself (via + # _omnygui_update_progress()) -- do NOT also call + # omnygui_show_progress() here: that re-raises the window to + # front on every single projection (confirmed live: on macOS + # this looks like the window closing and reopening every + # update), not just updates its values/text. tomo_scan()'s own + # unconditional call at scan start already shows/raises it + # once. Mirrors flomni's _tomo_scan_at_angle(), which likewise + # only ever calls _print_progress() per angle. self._print_progress() - self.omnygui_show_progress() while not successful: self._start_beam_check() if not self.special_angles: @@ -1613,6 +1621,7 @@ class OMNY( print(f"Total projections per subtomo: ... {self.progress['subtomo_total_projections']}") print(f"Estimated remaining time: ........ {eta_str}") print(f"Estimated finish time: ........... {finish_str}\x1b[0m") + self._omnygui_update_progress() def add_sample_database( self, samplename, date, eaccount, scan_number, setup, sample_additional_info, user diff --git a/tests/tests_bec_ipython_client/test_omny_tomo_scan.py b/tests/tests_bec_ipython_client/test_omny_tomo_scan.py index 92ec7928..80a11719 100644 --- a/tests/tests_bec_ipython_client/test_omny_tomo_scan.py +++ b/tests/tests_bec_ipython_client/test_omny_tomo_scan.py @@ -214,6 +214,33 @@ def test_tomo_scan_sets_timing_fields_on_new_scan(monkeypatch): # was ever printed). +def test_tomo_scan_at_angle_updates_progress_without_reraising_window(monkeypatch): + """_tomo_scan_at_angle() must only refresh the progress GUI's values/text + (via _print_progress() -> _omnygui_update_progress()), never call + omnygui_show_progress() again per angle -- that re-raises the window to + front on every single projection (confirmed live: on macOS this looks + like the window closing and reopening on every update). tomo_scan()'s + own unconditional call at scan start already shows/raises it once, + matching flomni's _tomo_scan_at_angle(), which likewise only ever calls + _print_progress() per angle.""" + omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="") + show_calls = [] + update_calls = [] + omny.omnygui_show_progress = lambda: show_calls.append(1) + omny._omnygui_update_progress = lambda: update_calls.append(1) + omny.special_angles = [] + omny._current_special_angles = [] + omny._start_beam_check = lambda: None + omny._was_beam_okay = lambda: True + omny._at_each_angle = lambda angle: None + omny._write_tomo_scan_number = lambda *a: None + + omny._tomo_scan_at_angle(10.0, 1) + + assert show_calls == [] + assert update_calls == [1] + + def test_tomo_scan_at_angle_tracks_idle_time_from_heartbeat_gap(monkeypatch, capsys): omny = make_omny_for_tomo_scan(monkeypatch, 45.0, active_account="") omny.tomo_countingtime = 0.1 # normal_cadence = max(60, 0.5) = 60s