fix(omny): stop re-raising the progress window on every projection
CI for csaxs_bec / test (push) Failing after 5s
CI for csaxs_bec / test (push) Failing after 5s
Mirko, on macOS: the progress window "seems to close and recreate each update, which is highly annoying" -- caused by _tomo_scan_at_angle() calling self.omnygui_show_progress() (the full show-window-and-raise-to- front routine) once per angle, on top of _print_progress(). flomni's own _tomo_scan_at_angle() never does this: it only ever calls _print_progress(), which calls self._flomnigui_update_progress() (values/text only) at its own end -- the window is shown/raised exactly once, by tomo_scan()'s unconditional call at scan start. Mirrored that structure: _print_progress() now calls self._omnygui_update_progress() itself, and the redundant per-angle omnygui_show_progress() call was removed from _tomo_scan_at_angle(). 1 new regression test. Full suite: 732 passed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLrD7sVYGLAzsQjLVJpCgt
This commit is contained in:
1 parent
afc13df24d
commit
68801cd901
3 files changed
+51
-4
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user