Skip to content

segmenter: honor stop requests during active segmentation - #952

Merged
sonnyp merged 3 commits into
mainfrom
fix/segmentation-stop-button
May 5, 2026
Merged

sonnyp merged 3 commits into
mainfrom
fix/segmentation-stop-button

Conversation

@babo989

@babo989 babo989 commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Adds a lightweight `_check_for_stop()` that's polled inside the per-image loop and
between folders, so the dashboard's Stop-segmentation button actually halts a running
pipeline.

  • drains stale MQTT messages and resets the interrupt flag at the start of `segment_list`
    (a stale click from a previous run can't kill the next one ideally)
  • publishes `Interrupted` instead of `Done` when user-stopped
  • skips writing `done.txt` so the folder can be retried"

@babo989

babo989 commented May 4, 2026

Copy link
Copy Markdown
Collaborator Author

It's working correctly in my test. From the timeline at 16:51:54–55:

16:51:54.085 segmenter/segment received: {"action":"stop"}
16:51:55.017 planktoscope.segmenter:_check_for_stop:602 — Stop requested during active
segmentation
16:51:55.017 10 images done … (current pipeline broke out of the for-loop at line 650)
16:51:55.052 planktoscope.segmenter:segment_path:943 — Pipeline interrupted by user for
/home/pi/data/clean/2026-03-28/Res1_1/Res1_1_A_2, not marking as done
16:51:55.554 segment_list:814 — Res1_1_A_3 starting (next queue item)

Every piece of the fix fired:

  • _check_for_stop() polled the MQTT queue mid-pipeline and consumed the stop message
  • The per-image loop broke out
  • segment_path saw _interrupt_requested == True and skipped writing done.txt
  • The Queue Processor saw Interrupted + seg_queue_user_stop, marked it as user-stopped, and
    advanced to the next acquisition (Res1_1_A_3) — which is exactly the "skip the current
    segmentation" semantic you wanted.

The button does what its label says now. No done.txt was written for the stopped folder, so
it can be retried later.

@sonnyp
sonnyp merged commit c739aa7 into main May 5, 2026
1 check passed
@sonnyp
sonnyp deleted the fix/segmentation-stop-button branch May 5, 2026 13:04
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.

2 participants