A running calibration can be aborted - #201
Merged
Merged
Conversation
"calibration routine -- while it is running, has no abort feature."
It runs for a minute or more — sixty to eighty exposures, each judged —
behind a disabled button, and there was no way to stop it short of
closing the tab. Now there is an Abort beside Calibrate, shown only
while a calibration runs.
WHAT ACTUALLY STOPS
The routine runs here, agent-side — Claude-vision edge search, adaptive
focus sweeps — as a long series of SHORT device-layer plans: a snap, a
move, a snap. There is nothing on the device layer to abort; each plan
is over in a fraction of a second. What has to stop is the tool's task
in the web process. The calibrate routes now run the tool as a task the
new POST /api/devices/calibrate/abort can cancel: the routine stops at
its next await, the plan in flight completes on its own, and every
positioner is halted after it. Then the calibrate request answers 409
"aborted by operator" — a 409 like the pre-flight refusal, because
nothing is broken and the operator chose it; the detail says which.
A cancellation that is ours — the tab closed — is re-raised unchanged,
so that still cancels the way it always did rather than reading as an
abort. Abort with nothing running answers {aborted: false}: a press a
moment too late is not a fault.
HALT COVERS THE PIEZO
Motion HALT stopped fdrive, XY and Z. The piezo is a stage to MMCore
too, and an aborted sweep leaves it wherever it was heading; it is in
the list now. The galvo is not a positioner and has no stop.
Tests drive the real routes over ASGI with a calibration that runs until
cancelled: abort cancels it, halts motion, the run answers 409, and the
finished task is unregistered; nothing running is not an error; the
batch route is abortable the same way; a client going away is not an
abort. Source guards pin the pane and the halt list.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It runs for a minute or more — sixty to eighty exposures, each judged — behind a disabled button, with no way to stop it short of closing the tab. Now there is an Abort beside Calibrate, shown only while a calibration runs.
What actually stops
The routine runs agent-side — Claude-vision edge search, adaptive focus sweeps — as a long series of short device-layer plans: a snap, a move, a snap. There is nothing on the device layer to abort; each plan is over in a fraction of a second. What has to stop is the tool's task in the web process.
/embryos/{id}/calibrateand/calibrate/all) now run the tool as a task thatPOST /api/devices/calibrate/abortcan cancel.await; the plan in flight completes on its own; every positioner is halted after it.409 … aborted by operator— a 409 like the pre-flight refusal, because nothing is broken and the operator chose it; the detail says which 409 it is, and the pane shows aborted rather than a failure.{aborted: false}— a press a moment too late is not a fault.HALT covers the piezo
Motion HALT stopped fdrive, XY and Z. The piezo is a stage to MMCore too, and an aborted sweep leaves it wherever it was heading; it's in the list now. The galvo is not a positioner and has no stop.
Tests
tests/test_calibration_can_be_aborted.pydrives the real routes over ASGI with a calibration that runs until cancelled: abort cancels it, halts motion, the run answers 409 with aborted, and the finished task is unregistered; nothing running is not an error; the batch route is abortable the same way; a client going away is a plain cancellation, not an abort. Two source guards pin the pane's button (shown only while running, wired inwire(), checked before the refusal branch since both are 409) and the halt list.Not verified on hardware: the halt of the piezo through
core.stop("PiezoStage:P:34")is the one call here the fakes cannot vouch for. If the controller declines it, HALT reports it inerrorsas it does for any axis, and the abort itself is unaffected.🤖 Generated with Claude Code