Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,48 @@ The original IvoryOS shows these arguments as text fields.
```

in a deck file (or `ivoryos_edge.run(__name__, plugins=[plr_ivoryos.labware_view.plugin])`) adds it
beside every page. **Edit layout** changes the worktable file as you go, with nothing to confirm:
beside every page. **Edit layout** changes the worktable file as you go, with nothing to confirm.
It shows the layout and the labware to place; the rest is under **⋯**, and **?** explains it all:

- what is mounted: the pipette on each mount or the 96-channel head, the gripper, the trash slot;
- what is mounted (**⋯ → Pipettes and gripper…**): the pipette on each mount or the 96-channel
head, the gripper, the trash slot;
- drag labware from PyLabRobot's catalogue (a Flex's own tip racks, and any plate, reservoir or
tube rack) onto an empty slot; drag what is there to move it, × to take it off, rename it in the
list;
- click a plate or reservoir, pick wells, and **Fill** them with a liquid and a volume: the
`liquids` a run starts from;
- **Import a layout…** takes a worktable file you already have; the one it replaces is kept as
- **⋯ → Import a layout…** takes a worktable file you already have; the one it replaces is kept as
`worktable.before-import.json`.

Steps offer added, moved or renamed labware, and changed equipment, once the deck restarts (the
panel offers the restart). The panel is the only part of this package that imports IvoryOS, and
Steps offer added, removed or renamed labware, and changed equipment, once the deck restarts (the
panel offers the restart). Moving labware, filling wells, and going back to the worktable the deck
started with need no restart. The panel is the only part of this package that imports IvoryOS, and
only IvoryOS NextGen loads it.

### Saved layouts

The worktable file is the layout in use. In **Edit layout**, the **Layout** row keeps others beside
it by name:

- **Save as…** saves the layout in use under a name. Once it has changed, **Save** and **Revert**
appear beside its name: Save keeps the changes in the layout it came from.
- The list switches to another saved layout. If the one in use has changes that are not saved, the
panel asks first.
- **Revert** goes back to the layout as it was saved. This is how a layout is changed for one
experiment: change it, run, revert. Until then the panel says what differs, "layout changed" or
"liquids changed" (topping up a reservoir is not a different layout), and the change survives a
restart.
- **⋯ → Download** gives the layout as a file, which **Import a layout…** takes on another deck.

Each saved layout is one worktable file in `worktable.layouts/` beside the worktable file
(`worktable.layouts/Dye dilution.json`). They are plain files, so the folder can be kept in a git
repository, and a file put there by hand is a saved layout like any other. `layouts_folder` puts
the folder somewhere else, for decks that share their layouts:

```python
flex = Flex(simulated=True, layouts_folder="/labs/flex-layouts")
```

---

## Installation
Expand Down Expand Up @@ -230,7 +257,8 @@ IvoryOS desktop app's decks do) uses the same plr-ivoryos and PyLabRobot.
- **PyLabRobot 1.0 only.** The 0.2 `LiquidHandler`, its worktables for the OT-2, Hamilton and Tecan
robots, and the single-purpose devices (`Scale`, `Pump`, `PlateReader`, `Sealer`, ...) are gone:
they wrapped PyLabRobot's older interfaces, which 1.0 keeps only as `pylabrobot.legacy`. Saved
workflows using them need redoing.
workflows using them need redoing. Where each robot is now, and what is planned:
[docs/liquid-handlers.md](docs/liquid-handlers.md).
- **The Opentrons Flex**, its mounts and gripper as instruments, and a simulated Flex.
- No steps of this package's own design: no `transfer`, no "next unused tips" from a bare rack name.
Steps are PyLabRobot's.
Expand Down
68 changes: 68 additions & 0 deletions docs/liquid-handlers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Liquid handlers: where each one is

Checked 2026-11-22 by reading and running PyLabRobot 0.2.2 and 1.0.0b1. No robot in this table has
been run on real hardware with this package, in either line.

## The two lines of this package

- **0.2.x** is for PyLabRobot 0.2.x. Every robot is one instrument, PyLabRobot's old
`LiquidHandler`, with the same steps on each (`aspirate`, `dispense`, `transfer`, `pick_up_tips`,
`move_plate`, ...) and PyLabRobot's generic simulator.
- **1.0** is for PyLabRobot 1.0. Each robot has its own class and each thing mounted on it is an
instrument of its own, with PyLabRobot's step names. Only the Flex is done.

## Robot by robot

| Robot | This package 0.2.x | Where it is in PyLabRobot 1.0.0b1 | This package 1.0 |
| :--- | :--- | :--- | :--- |
| Opentrons Flex | not included | `pylabrobot.opentrons`: `Flex`, `FlexHead1`, `FlexHead8`, `FlexHead96`, `FlexGripper`. No simulator. | Done, with this package's simulator |
| Opentrons OT-2 | included | `pylabrobot.opentrons`: `OT2`, `OT2SingleChannelPipette`, `OT2_8ChannelPipette`. No simulator. | Not done. Needs a simulator written first. |
| Hamilton STAR, STARlet | included | `pylabrobot.hamilton.star`: `STAR`, `STARlet`, `STARPlus`, with `STARSimulationDriver` | Not done. Can be built against PyLabRobot's simulator. |
| Hamilton Prep | not included | `pylabrobot.hamilton.prep`: `Prep`, with `PrepSimulationDriver` | Not done |
| Hamilton Nimbus | included | only `pylabrobot.legacy` | Not planned |
| Hamilton Vantage | included | only `pylabrobot.legacy` | Not planned |
| Tecan EVO 100, 150, 200 | included | only `pylabrobot.legacy` | Not planned |

Already in the 1.0 line for the OT-2 and the STAR: the worktable file builds their decks
(`OTDeck`, `STARDeck`, `STARLetDeck` in `worktable.py`), and the Labware view draws any robot.
What is missing is the driver class for each, like `opentrons/flex.py` for the Flex.

## What the robot can do, 0.2 against 1.0

| | PyLabRobot 0.2.2 | PyLabRobot 1.0.0b1 |
| :--- | :--- | :--- |
| OT-2 | tips, aspirate, dispense, home | the same, plus mix, return and discard tips, move-to, and the 8-channel as its own class |
| STAR | channels, 96 head, iSWAP, CoRe grippers, autoload | the same, plus 384 head and STARPlus |

So 1.0 is not a step down for these two. The OT-2 is thin only next to the Flex.

## What does not carry over

A workflow written for a 0.2 robot has to be rewritten for the same robot on 1.0: the instrument
names and the step names are different (`star.aspirate` becomes a step on one of the STAR's
parts). This is on purpose: 1.0 uses PyLabRobot's own names and does not try to make one workflow
run on two kinds of robot.

## The legacy route

`pylabrobot.legacy` in 1.0.0b1 still holds the old `LiquidHandler`, its backends (STAR, Vantage,
Nimbus, EVO, OT-2) and its simulator. It started and stopped on all eight old worktables; no step
was run on it. PyLabRobot marks it legacy and tells callers to move off it, and this package's 0.2
code does not run on it as it is (14 of its 32 tests fail on 1.0.0b1). This package does not use
it. It is the only route to a Nimbus, Vantage or EVO on PyLabRobot 1.0, if someone asks for one.

## Versions

- The first two numbers follow PyLabRobot; the third is this package's own.
- While PyLabRobot 1.0 is in beta, each beta here (1.0.0b2, 1.0.0b3, ...) is pinned to exactly one
PyLabRobot beta. After PyLabRobot 1.0.0: `pylabrobot>=1.0,<1.1`, and 1.0.1, 1.0.2 at our pace.
- 0.2.x gets fixes only. **0.2.1 is prepared and not published**: branch
`fix/pylabrobot-below-1` requires `pylabrobot>=0.2.2,<1.0`. The published 0.2.0 has no upper
bound, so it will break when PyLabRobot 1.0 is final. On 2026-11-22 that branch passed its tests
on PyLabRobot 0.2.2 and ran a simulated STARlet and OT-2 with the current IvoryOS edge.

## Order of work, when picked up

1. Hamilton STAR and STARlet on 1.0 (a simulator exists).
2. Opentrons OT-2 on 1.0 (write the simulator first, as was done for the Flex).
3. Nimbus, Vantage, EVO only when someone needs one.
89 changes: 89 additions & 0 deletions docs/opentrons-flex-control-landscape.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Controlling an Opentrons Flex: what exists

Notes from a survey on 2026-11-22, kept so it does not have to be repeated. It covers what
PyLabRobot 1.0.0b1 (the version this package is pinned to) does on a Flex, the ways Opentrons
itself offers to control one, and the other open-source projects found. Stars and dates are as
seen that day.

## What PyLabRobot 1.0.0b1 covers

Read from the installed package (`pylabrobot/opentrons`).

**Included**

- Connection over Ethernet or USB, runs, homing, rail lights, status bar, comments, timed waits.
- 1-, 8- and 96-channel pipettes: tips (pick up, drop, discard, presence check), aspirate,
dispense, blow out, air gap, touch tip, configure for volume, move to a well or a coordinate.
Liquid level probing on the 1- and 8-channel; `mix` and single-nozzle use on the 8-channel.
- Gripper: `move_labware(resource, to_slot)`, slot to slot only, including staging slots A4 to D4.
Also low-level `move_to_position`, `grip`, `ungrip`.
- Labware: any PyLabRobot definition is converted and uploaded to the robot; official Opentrons
tip racks are used as they are.
- Reading what is attached: pipettes, gripper, modules, deck fixtures.
- `Flex.send_command(command_type, params)`: any robot command by name. It validates nothing and
does not update PyLabRobot's tip, volume or labware tracking.
- `labware_moved_off_deck` and `reload_labware`, for labware a person or another arm moved.

**Not included** (no code found)

- Running a module: Heater-Shaker, Temperature Module, Thermocycler, Magnetic Block, Absorbance
Plate Reader, Flex Stacker. Attached modules can be listed, not driven.
- Moving labware onto a module or an adapter with the gripper, and pick-up or drop offsets.
- Lids, the waste chute.
- Opentrons liquid classes, and the robot's saved labware offsets (Labware Position Check).
- Pausing until a person resumes.
- Uploading or running an Opentrons protocol file: PyLabRobot sends one command at a time.

The OT-2 class is much thinner than the Flex one (not thinner than the OT-2 in PyLabRobot 0.2:
see [liquid-handlers.md](liquid-handlers.md)): connect, home, and single- or 8-channel pipettes
with aspirate, dispense, mix, tips and move-to. Thermocyclers (Opentrons, Inheco, Thermo Fisher) exist only under
`pylabrobot.legacy`, which this package does not use.

## What Opentrons itself offers

- **Protocol API** (`opentrons.protocol_api`): a Python file with a `run(protocol)` function,
uploaded and run as a whole. Covers every module, lids, adapters, the waste chute. A run can be
paused, resumed and stopped from outside, and the Flex has an error-recovery state for some
failures, but what the run does next cannot be changed once it has started.
- **HTTP API** (the robot-server, port 31950): protocol upload and runs (`/protocols`, `/runs`,
`/runs/{id}/actions`), result files (`/dataFiles`), and **single commands** posted to a run with
no protocol (`/runs/{id}/commands`). Every Protocol API call has a command underneath
(`heaterShaker/closeLabwareLatch`, `absorbanceReader/read`, `moveLabware` to a module, ...).
This is the interface PyLabRobot uses, and what `send_command` passes through to.
Reference: <https://docs.opentrons.com/http/api_reference.html>
- **Jupyter on the robot**: Protocol API calls one cell at a time
(<https://docs.opentrons.com/python-api/advanced-control/jupyter/>). Labware offsets have to be
set by hand in this mode. Not a route this package takes.
- **Definitions**: labware, deck and module geometry are JSON files in Opentrons' `shared-data`
(<https://github.com/Opentrons/opentrons>). A custom labware is the same kind of file, uploaded
with a protocol. On GitHub the Flex is called `ot3`.

## Other open-source projects

Found by GitHub repository search, GitHub code search for module commands
(`"heaterShaker/closeLabwareLatch"`, `"absorbanceReader/read"`, `"flexStacker/retrieve"`), and web
search. None is widely adopted.

| Project | What it is | Flex and modules | Seen 2026-11-22 |
| :--- | :--- | :--- | :--- |
| [AccelerationConsortium/opentrons-flex](https://github.com/AccelerationConsortium/opentrons-flex) | SiLA 2 connector (UniteLabs CDK) that runs on the Flex in place of the robot-server; has a simulator | Heater-Shaker, Absorbance Plate Reader, Stacker, Temperature Module, Thermocycler, lids, gripper moves; can keep the HTTP API available | 3 stars, pushed 2026-11-02, no license file |
| [AccelerationConsortium/opentrons-ot2](https://github.com/AccelerationConsortium/opentrons-ot2) | The same idea for the OT-2 | OT-2 | 6 stars, pushed 2026-10-14, no license file |
| [usnistgov/AFL-automation](https://github.com/usnistgov/AFL-automation) (`AFL/automation/prepare/OT2HTTPDriver.py`) | Lab framework with a driver that posts single commands to the HTTP API and keeps deck state | Written for the OT-2; loads modules, moves labware | 19 stars, pushed 2026-11-13 |
| [AD-SDL/ot2_module](https://github.com/AD-SDL/ot2_module) | Node for Argonne's MADSci framework | README says OT-2 and Flex; depth not checked | 1 star, pushed 2026-10-29 |
| [rickwierenga/opentrons-python-api](https://github.com/rickwierenga/opentrons-python-api) | Thin wrapper around the HTTP API (used by PyLabRobot's legacy OT-2 backend) | Describes itself as incomplete | 11 stars, pushed 2025-11-26, MIT |
| [FlorianBauer/ot2-controller](https://github.com/FlorianBauer/ot2-controller) | SiLA 2 controller | OT-2 only | 15 stars, pushed 2023-06-04, Apache-2.0 |
| [Hendricks-Laboratory/OT2Control](https://github.com/Hendricks-Laboratory/OT2Control) | OT-2 control software | OT-2 only | 8 stars, pushed 2026-11-16, no license file |
| [Opentrons/opentrons-integration-tools](https://github.com/Opentrons/opentrons-integration-tools) | Opentrons' own guides for external devices | Guides, not a driver | 34 stars, pushed 2023-08-30 |
| [y3rsh/flex-talk](https://github.com/y3rsh/flex-talk) | TypeScript client for the Flex HTTP API | Not checked | 0 stars, pushed 2026-03-29 |

Several MCP servers for Opentrons also exist (for example
[yerbymatey/opentrons-mcp](https://github.com/yerbymatey/opentrons-mcp)); they generate or submit
protocols and are not drivers.

## What this means for this package

A step for something PyLabRobot does not wrap (a Heater-Shaker, the plate reader, a lid) does not
have to wait for PyLabRobot: the robot command exists, and `send_command` sends it. Such a step
would be this package's own to write and maintain, PyLabRobot would not track labware it moves,
and it cannot be tested without a Flex that has the module, since the simulator here does not model
modules.
48 changes: 39 additions & 9 deletions plr_ivoryos/labware_view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,35 @@
up while it runs. With "Edit layout" it changes the worktable the way a person changes the real
one, saved to its worktable file: what is mounted on the robot, drag labware from PyLabRobot's
catalogue onto a place (or a carrier onto the tracks), drag what is there to move it, rename or
remove it, fill wells with a liquid, or import a layout someone already has. Nothing moves.
remove it, fill wells with a liquid, or import a layout someone already has. A layout is saved
under a name, switched to, gone back to as it was saved, and downloaded as a file. Nothing moves.

Only IvoryOS NextGen loads this module, and it provides `ivoryos_edge`; the rest of plr-ivoryos
does not import it. Served at /plugins/labware/ (page), /plugins/labware/api/{layout,state,
catalog,edit} and /plugins/labware/events.
catalog,edit,export} and /plugins/labware/events.
"""

import json
import os
from typing import Optional
from urllib.parse import quote

from fastapi.responses import FileResponse, JSONResponse
from fastapi.responses import FileResponse, JSONResponse, Response
from ivoryos_edge.plugins import Plugin

plugin = Plugin("Labware", id="labware", page="page", placement="panel-right", icon="grid-3x3")

# Worktables changed since this process started: steps offer the change only after a restart, and a
# page opened (or reloaded) in between should still say so.
# page opened (or reloaded) in between should still say so. Only for a worktable that does not say
# itself whether it still is what the deck started with (`deck.restart_needed`).
_restart_pending: set = set()


def _needs_restart(name: str, found: dict) -> bool:
told = (found.get("deck") or {}).get("restart_needed")
return told if isinstance(told, bool) else name in _restart_pending


def _call(instrument, method: str, *args):
found = getattr(instrument, method, None)
if not callable(found):
Expand All @@ -50,8 +60,9 @@ def _worktables() -> dict:


def layout() -> dict:
return {"worktables": {name: found for name, (_, found) in _worktables().items()},
"restart_needed": sorted(_restart_pending)}
worktables = {name: found for name, (_, found) in _worktables().items()}
return {"worktables": worktables,
"restart_needed": sorted(name for name, found in worktables.items() if _needs_restart(name, found))}


def state() -> dict:
Expand All @@ -66,7 +77,8 @@ def on_event(event, name=name, instrument=instrument):
# A change to the worktable itself means the page reads the layout again.
plugin.publish({"worktable": name, "event": event,
"state": _call(instrument, "__ivoryos_labware_state__") or {},
"relayout": event.get("action") in ("move", "layout")})
# "load" too: filling wells changes whether a saved layout still matches.
"relayout": event.get("action") in ("move", "layout", "load")})

_call(instrument, "__ivoryos_labware_events__", on_event)

Expand All @@ -92,6 +104,23 @@ def get_pylabrobot(worktable: str, part: str = "layout"):
return FileResponse(path, media_type="application/json", filename=os.path.basename(path))


@plugin.router.get("/api/export")
def get_export(worktable: str, layout: Optional[str] = None):
"""A layout as a file, as a download: the one in use, or a saved one by name. It is the file
"Import a layout" takes."""
found = _worktables().get(worktable)
give = getattr(found[0], "__ivoryos_labware_export__", None) if found else None
if not callable(give):
return JSONResponse(status_code=404, content={"error": "This worktable cannot be downloaded."})
try:
result = give(layout or None)
except ValueError as e:
return JSONResponse(status_code=404, content={"error": str(e)})
filename = str(result.get("filename") or "worktable.json")
return Response(json.dumps(result.get("layout") or {}, indent=2) + "\n", media_type="application/json",
headers={"Content-Disposition": f"attachment; filename*=UTF-8''{quote(filename)}"})


@plugin.router.get("/api/catalog")
def get_catalog():
"""Per worktable: what can be put on it and which robots it can become. Empty lists for one
Expand Down Expand Up @@ -119,6 +148,7 @@ def edit(change: dict):
result = result if isinstance(result, dict) else {}
if result.get("restart", True):
_restart_pending.add(str(change.get("worktable")))
return {"layout": layout(), "catalog": get_catalog()["worktables"], "state": state(),
"restart_needed": bool(result.get("restart", True)), "name": result.get("name"),
now = layout()
return {"layout": now, "catalog": get_catalog()["worktables"], "state": state(),
"restart_needed": str(change.get("worktable")) in now["restart_needed"], "name": result.get("name"),
"kept": os.path.basename(result["kept"]) if result.get("kept") else None}
Loading
Loading