Skip to content

enh: pause button for the analysis (#9) - #27

Merged
paulmueller merged 2 commits into
DC-analysis:mainfrom
paulmueller-agent:pause-button
Nov 26, 2026
Merged

paulmueller merged 2 commits into
DC-analysis:mainfrom
paulmueller-agent:pause-button

Conversation

@paulmueller-agent

@paulmueller-agent paulmueller-agent commented Nov 26, 2026 •

Copy link
Copy Markdown

Closes #9.

Approach

As in CSKernel's postprocessing (cskernel/postproc/pp_base.py, psutil.Process.suspend() for the subprocess and its children), the analysis is paused by suspending the dcnum worker processes. No change in dcnum is needed for this. Threads in the GUI process (job manager, dcnum runner) are not suspended; they just wait for the suspended processes.

I tested this with the 30000-event Naiad reference dataset (DCOR naiad-reference-data). I suspended all child processes for 60 s, resumed them, and compared the result with an unpaused run:

paused during result
background computation identical output (events, deform, area_um, frame, pipeline hash)
segmentation / feature extraction (33 %) identical output; no CPU time used by the suspended processes
start of the universal workers job fails with "Universal workers failed to spawn" (dcnum waits only 10 s per worker) → fixed in DC-analysis/dcnum#119

While paused, dcnum may start new processes: its worker starter thread runs in the GUI process, and so does the next job. These are suspended as well (see below).

Changes

  • ChipStreamJobManager.pause():
    • suspends all child processes of the GUI process with psutil (NtSuspendProcess on Windows, SIGSTOP on POSIX)
    • starts a daemon thread that suspends new child processes every 0.2 s until resume() is called
  • resume() resumes all suspended processes. close() (e.g. when the window is closed) resumes them before killing them.
  • is_paused(); while paused, the current job's state in the job list is "paused".
  • Main window: a checkable "Pause"/"Resume" button below "Run Pipeline", visible only while the analysis is running. Because this button sits in the options panel, a run now disables the three option group boxes and the run button individually instead of the whole panel. When the run is completed, the jobs are resumed (in case) and the button is hidden.

Caveats

Tests

  • test_manager_pause_resume: pauses before starting a job with worker processes (debug=False). After 10 s, the job is still busy and shown as "paused", all child processes are in the stopped state, and the progress does not change. After resume(), the job finishes ("done", progress 1).
  • test_gui_pause_button: the button is only visible while running; clicking it pauses (button text "Resume") and clicking again resumes; after the run, the options are enabled again and the button is hidden.

Both fail on main and pass with the change. tests/test_gui_manager.py and the GUI tests for basic operation, expert settings, the model list, the status bar, and the pixel size pass. In test_gui_expert_kwargs_invalid, the check that the options are still enabled now checks the run button (the options panel itself is no longer disabled).

Follow-up: test isolation (second commit)

The first CI run failed in test_gui_pause_button ("MD5 mismatch for .../Alpha.dcnm"). The cause was not the pause itself but test_gui_segm_torch_models_sorted from #26, which runs before it:

  • It added copies of the test model named Alpha.dcnm, beta.dcnm, etc. dcnum requires a model file name to end with the beginning of its MD5 sum (..._910c2.dcnm), so these files cannot be used for segmentation.
  • It also left the temporary model directory in the user settings. Every ChipStream window created afterwards preselects the "Machine-learning model" segmenter with the first sorted model (Alpha.dcnm), and any pipeline run in a later test fails. In enh: sort the list of segmentation models by name #26, no such test ran after it.

Fix:

  • test_gui_segm_torch_models_sorted names the copies <name>_910c2.dcnm and restores the segm/torch_model_files setting afterwards.
  • test_gui_pause_button selects the thresholding segmenter explicitly.

Lint

lint-compare against main: ruff 0 → 0, pyright 1.1.408 0 → 0, flake8 clean.

🤖 Generated with Claude Code

- `ChipStreamJobManager.pause` suspends all child processes (the dcnum
  worker processes) with psutil, as CSKernel does for postprocessing.
  A background thread also suspends child processes that dcnum starts
  while paused. `resume` resumes them, and `close` resumes before
  killing. The current job is shown as "paused" in the job list.
- A checkable "Pause"/"Resume" button below "Run Pipeline" is shown
  while the analysis is running. During a run, the option group boxes
  and the run button are disabled individually (instead of the whole
  options panel), so that the pause button stays usable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.70588% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.80%. Comparing base (f7870ce) to head (978e50b).

Files with missing lines Patch % Lines
chipstream/gui/manager.py 84.44% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
+ Coverage   80.08%   80.80%   +0.71%     
==========================================
  Files          23       23              
  Lines        1622     1688      +66     
==========================================
+ Hits         1299     1364      +65     
- Misses        323      324       +1     

☔ 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.

`test_gui_segm_torch_models_sorted` (DC-analysis#26) added copies of the test
model with names that do not end with the MD5 sum ("Alpha.dcnm"), which
dcnum rejects, and left their directory in the user settings. Every
later ChipStream window preselected the machine-learning segmenter with
"Alpha.dcnm", so the pipeline in `test_gui_pause_button` failed with
"MD5 mismatch".

- name the model copies "<name>_910c2.dcnm" and restore the
  "segm/torch_model_files" setting after the test
- select the thresholding segmenter in `test_gui_pause_button`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulmueller
paulmueller merged commit 8194f0e into DC-analysis:main Nov 26, 2026
8 checks 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.

Add a pause button

2 participants