Skip to content

Fix zero-total acquisition progress and thread exception logging - #1251

Merged
kevin-m-dean merged 2 commits into
developfrom
kdean/fix-acquisition-progress-zero
Sep 29, 2026
Merged

kevin-m-dean merged 2 commits into
developfrom
kdean/fix-acquisition-progress-zero

Conversation

@kevin-m-dean

@kevin-m-dean kevin-m-dean commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

A Z-stack frame can reach the progress display with number_z_steps == 0, raising ZeroDivisionError and interrupting the capture loop. The worker's exception handler then raises a logging-format TypeError, obscuring the original failure.

This change handles nonpositive Z-stack totals by resetting both progress bars and showing --:--:-- for remaining time; normal progress resumes when valid totals return. Stop now cancels progress timers before reading acquisition state, including when no frames have arrived. Both thread exception handlers use valid logging arguments and preserve the original traceback through QueueHandler.

Validation:

  • 105 acquisition, channel-settings, controller, and thread tests passed on macOS/Python 3.9.
  • Ten new regressions cover zero/negative totals, recovery, stopping before the first frame, queue-compatible tracebacks, and resource reuse after worker failure. Observed failures before the fix.
  • Repository pre-commit hooks (including Black and Ruff) and current Ruff lint passed.
  • The initial full-suite run exposed two order-dependent failures in the new logging tests after application logging was configured. Isolated their logger and reran all 105 targeted tests in that order successfully. Stopped the superseded full run at approximately 33%; the full local suite is not claimed passing. Windows CI is pending on the final revision.

The existing progress and thread handlers are repaired in place; the implementation and reuse rationale are recorded in b87f77cd4. Test isolation is corrected in beab0116a.

Avoid dividing by nonpositive Z-stack image totals in progress updates,
show unknown remaining time, and allow later valid updates to recover.
Always stop progress timers before reading acquisition state, including
when capture stops before its first image. Repair both thread exception
handlers so QueueHandler retains the original traceback without a
formatting error.

Reuse analysis:
- Repair AcquireBarController.progress_bar and its existing stop helper.
- Repair the existing SelfLockThread and SynchronizedThreadPool handlers;
  no parallel progress, validation, or logging abstraction is added.
- Document the progress fallback and stop behavior in the owning method.

Validation: 105 acquisition/controller tests passed, including 10 new
regressions; repository pre-commit hooks and Ruff lint passed.
Copilot AI balanced review requested due to automatic review settings September 28, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fixes are consistent with the described failures and have appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes acquisition progress handling for invalid totals and preserves thread exception tracebacks.

Changes:

  • Safely resets progress for invalid Z-stack totals and early stops.
  • Corrects exception logging in worker threads.
  • Adds regression coverage for progress and thread recovery.
File Description
src/​navigate/​controller/​sub_controllers/​acquire_bar.py Handles invalid totals and stopping safely.
src/​navigate/​controller/​thread_pool.py Corrects exception logging calls.
test/​controller/​sub_controllers/​test_acquire_bar.py Tests invalid totals, recovery, and stopping.
test/​controller/​test_thread_pool.py Tests traceback logging and resource reuse.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.18%. Comparing base (3de2eb2) to head (beab011).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1251      +/-   ##
===========================================
+ Coverage    67.16%   67.18%   +0.01%     
===========================================
  Files          210      210              
  Lines        31068    31072       +4     
===========================================
+ Hits         20868    20876       +8     
+ Misses       10200    10196       -4     
Flag Coverage Δ
unittests 67.18% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kevin-m-dean
kevin-m-dean merged commit 0699e9d into develop Sep 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants