Skip to content

OT2: a run left unfinished on the robot - #1588

Merged
rickwierenga merged 2 commits into
PyLabRobot:mainfrom
AskeU:ot2-unfinished-run
Nov 12, 2026
Merged

rickwierenga merged 2 commits into
PyLabRobot:mainfrom
AskeU:ot2-unfinished-run

Conversation

@AskeU

@AskeU AskeU commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A run left unfinished (a script stopped half way, a protocol loaded or paused in the Opentrons
App) keeps the robot from creating another; setup() failed with the server's bare 409.

 RunInfo(id, status)
+  current: Optional[bool]       # from the run listing
+  created_at: Optional[str]
+  finished -> bool              # stopped, failed or succeeded

 OT2
+  get_run(run_id)
+  get_unfinished_run() -> Optional[RunInfo]
+  stop_run(run_id, timeout=None) -> RunInfo
+    read the run; finished -> leave it
+    stop it; wait until finished, else TimeoutError
   setup()
     get_health, get_mounted_pipettes
+    get_unfinished_run -> RuntimeError naming it
     create_run ...
   home()
-    requires a run
+    requires a connection    # homing is a robot endpoint, not a run command

Evidence

  • Before: setup() beside an unfinished run: HTTPError 409. Stopping it meant
    ot2._api.stop_run and polling ot2._api.get_run.
    After: setup() raises RuntimeError: The OT-2 holds an unfinished run <id> (idle, created ...), before creating anything; stop_run stops it and waits; home() after it works without
    a run. 9 new tests; 525 passed.
  • Run on an OT-2: a run left open by a setup never stopped; setup() refused beside it, naming
    it; stop_run stopped it and a new run was set up. And a script stopped half way, its run
    stopped, the robot homed, a new run set up.

Merge Danger

Door: two-way

Blast Radius: small

setup() sends one more request (GET /runs) and refuses earlier, with a clearer message, where
it already failed. home() now works on a connection alone, where it raised before.

🤖 Generated with Claude Code

A run another client or an earlier session leaves unfinished (a script
stopped half way, a protocol loaded or paused in the Opentrons App)
keeps the robot from creating another. RunInfo carries what the run
listing says about it: whether it is the current run, when it was
created, and whether its status is finished. OT2.get_unfinished_run
finds it, and OT2.stop_run stops a run by id and waits until the robot
reports it finished, leaving a finished one as it is. setup refuses an
unfinished current run, naming it, before creating its own.

OT2.home needs a connection rather than a run: homing is a robot
endpoint, and after stop_run it brings the robot back to a known
position before setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AskeU
AskeU requested a review from a team as a code owner November 6, 2026 14:06
@AskeU AskeU changed the title OT2: a run left unfinished on the robot OT2: a run left unfinished on the robot Nov 6, 2026
@rickwierenga
rickwierenga merged commit 66cb37c into PyLabRobot:main Nov 12, 2026
25 of 26 checks passed
@rickwierenga

Copy link
Copy Markdown
Member

thanks!

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