labwire-ophyd
Expose any ophyd device as a Labwire instrument, so AI agents can discover and drive the largest existing body of Python instrument drivers through one protocol, with the units, safety classes, and signed results ophyd itself does not carry.
ophyd abstracts hardware for Python programmers. Labwire describes hardware to AI agents. This bridge composes them; Labwire does not reimplement drivers.
Five-minute quickstart
Nothing here needs hardware. From a checkout with make setup done:
# 1. See what the bridge works out on its own, and what it cannot
uv run labwire-ophyd annotate ophyd.sim:motor -o labwire-ophyd.yaml
# 2. Fill in every TODO in that file (ophyd.sim reports no units at all),
# then check what Labwire would expose
uv run labwire-ophyd check ophyd.sim:motor --annotations labwire-ophyd.yaml
# 3. Watch a full scan run through the protocol, with signed evidence
make demo-ophyd
labwire-ophyd check prints the resolved instrument: every channel with its
UCUM unit, every command with its safety class:
OK: SynAxis (motor)
2 channel(s), 4 component(s), 3 command(s)
S1 read
S2 move
S0 stop
motor: mm
motor_setpoint: mm
Serving it is a few lines:
from labwire.bridges.ophyd import OphydInstrument, load_annotations
from labwire.core import InstrumentServer
instrument = OphydInstrument(device, load_annotations(Path("labwire-ophyd.yaml")))
server = InstrumentServer(instrument, confirmation_token="operator-grant")
async with server.serve_websocket("127.0.0.1", 9520):
...
The annotation file
ophyd knows a device's structure but not its meaning: ophyd.sim devices
report no units, EPICS reports free-text .EGU strings, and ophyd has no
concept of a safety class at all. The annotation file supplies exactly that
layer, and it is what makes a device safe for an agent to operate.
version: 1
devices:
ophyd.sim.SynAxis: # keyed by class; subclasses inherit it
description: A sample stage.
intent_tags: [motion]
components:
readback:
unit: mm # UCUM, never guessed for you
qudt_quantity_kind: Length
dtype: float64 # ophyd infers dtype from the current value
setpoint: {unit: mm, dtype: float64}
velocity: {unit: mm/s}
acceleration: {unit: mm/s2}
commands:
trigger: {exclude: true} # meaningless for a stage
move: {estimated_duration_s: 2.0}
instances:
fine_stage: # keyed by Device.name; overrides the class
components:
setpoint: {limits: {low: -5.0, high: 5.0}}
Rules worth knowing:
- Merging is per field, along the class MRO and then the instance, so an override touches only what it names.
- Unknown keys, components, and commands are errors. A typo that silently annotated nothing would be worse than a failure.
- Missing units are refused, naming the exact component and the YAML path
that would fix it.
--allow-partialomits those components instead, and still reports every one. - Annotated
limitsintersect with the device's own control limits: the tightest bound on each side wins. settable: falsekeeps a channel but removes its actuation command, for the readings ophyd technically lets you write, such as a detector's computed value.
A working example lives at
examples/ophyd_scan/labwire-ophyd.yaml.
Mapping
| ophyd | Labwire |
|---|---|
Device.name |
instrument serial number (model = class name) |
Kind.hinted / Kind.normal |
telemetry channel |
Kind.config |
descriptor metadata |
Kind.omitted |
skipped |
describe()[…]["units"] |
UCUM unit, after EGU translation |
lower_ctrl_limit / upper_ctrl_limit |
parameter minimum / maximum |
Device.set() on a positioner |
move, safety class S2 |
signal.set() elsewhere |
set_<attr>, safety class S2 |
Device.trigger() |
trigger, safety class S1 |
Device.stop() |
stop, safety class S0 |
command/cancel |
refused for most commands; EpicsMotor-family moves declare abort and settle only what the status object confirms |
| ophyd failures | HardwareFaultError / DeviceTimeoutError |
Safety defaults lean toward friction, because ophyd carries no safety
information and guessing low is the failure that moves hardware: actuation is
S2 (an agent must present an operator confirmation), acquisition is S1, and
stop is S0 so recovery stays available even while an interlock is tripped.
Changing a class takes an explicit annotation, never a heuristic.
DESIGN.md has the full reasoning, including why positioners are moved rather than poked.
Why this bridge declares no resources
Protocol v0.3 added resources for instrument state that is a tree with
nowhere else to live. An ophyd device has none: its structure is fixed by
its class and is already fully expressed as the descriptor plus scalar
channels, so inventing a resource here would be adding surface to prove a
point. The bridge declares resources: [], which costs a signal-shaped
instrument exactly nothing, and that asymmetry is useful evidence about the
primitive itself.
One v0.3 change does reach this bridge: a CommandAnnotation.safety_class
of S3 now genuinely bites. An S3 command requires an operator grant from
a server-side store (labwire grant), and a server with S3 commands and no
store refuses to start; see SPEC 8.6 before raising a command's class.
LIMITATIONS
Read this before believing anything above.
-
No physical hardware, ever. The bridge is exercised against
ophyd.simdevices and against a pure-Python EPICS soft IOC (caproto) over Channel Access. It has never been connected to a real instrument, a production IOC, or any beamline, and no claim is made about NSLS-II, APS, Diamond, or any other facility. -
Classic synchronous ophyd only.
ophyd-asyncis not supported. -
Units are validated for presence, not grammar. The EGU→UCUM table covers conventional beamline spellings and is convention-based; it has not been checked against a UCUM implementation.
-
Cancellation is declared per command, and the record earns its claims.
ophyd.simaxes'stop()is literallypass(their move completes no matter what), so theirmovedeclarescancel_semantics: "none"and a mid-run cancel is refused rather than reported as done.EpicsMotor-family devices declare"abort", because theirstop()writes the motor record's .STOP field; after a stop, the move's status object must resolve within a settlement window before the record claims a halt, and otherwise the settlement is"unconfirmed", which means exactly what it says. An annotation may downgrade any command to"none"; declaring"abort"in an annotation is a truth claim about the bench, not a preference. TODO-VERIFY: the abort path has never run against a real EPICS IOC. -
ophyd is synchronous. Every call runs in a worker thread, so the server keeps answering, but a badly behaved device still occupies a thread.
-
Array- and enum-valued signals are refused: Labwire v0.2 channels carry scalars, and non-numeric channels still need an explicit unit.
-
Move progress is not reported.
MoveStatus.watch()yields no useful intermediate fractions on simulated devices, so the bridge does not fabricate one.
Licensing
ophyd is a separate BSD-3 project from the Bluesky collaboration (Brookhaven
National Laboratory and contributors), and caproto is BSD-3 as well. Both are
optional dependencies here: not vendored, not forked, not modified. See
the repository NOTICE.
Metadata
Release files for labwire-ophyd 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labwire_ophyd-0.5.0.tar.gz | 35.8 kB | With provenance | Details for labwire_ophyd-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labwire_ophyd-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for labwire_ophyd-0.5.0-py3-none-any.whl |
Total release size: 62.0 kB
Release files / labwire_ophyd-0.5.0.tar.gz
| Download URL | labwire_ophyd-0.5.0.tar.gz |
|---|---|
| Size | 35.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
426e91d8e83cdea121c352d76c72ed82f5c522b87afacd699a6ef4dbd507f193
|
|
BLAKE2b-256 checksum How to use checksums |
c8113539dde95cd9929f538fd58220c9df32a59c58457392ecac47dff0c6ddd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logRelease files / labwire_ophyd-0.5.0-py3-none-any.whl
| Download URL | labwire_ophyd-0.5.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
902f8ac1dd3b228489059b44dcfe113c8b68bb0f52c00edd26aac83aa1d636f2
|
|
BLAKE2b-256 checksum How to use checksums |
3484945d873998c56526af8bcbdd964d76e4b9ac324802a2cfd18f5b69fad1a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logSecurity for labwire-ophyd 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for labwire_ophyd-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.