Skip to content

Port Hamilton Nimbus to v1b1 architecture#986

Open
rickwierenga wants to merge 3 commits intov1b1from
nimbus-v1b1
Open

Port Hamilton Nimbus to v1b1 architecture#986
rickwierenga wants to merge 3 commits intov1b1from
nimbus-v1b1

Conversation

@rickwierenga
Copy link
Copy Markdown
Member

Summary

  • Decomposes the monolithic legacy NimbusBackend (2312 lines) into the three-layer v1b1 Device/Driver/Backend architecture matching the STAR port
  • Promotes the shared Hamilton TCP protocol layer to pylabrobot/hamilton/tcp/ and converts legacy submodules to thin re-export shims (~2,470 lines of duplication eliminated)
  • Legacy NimbusBackend becomes a thin wrapper delegating to the new code while maintaining the exact same API

New files

File Class Role
nimbus/nimbus.py Nimbus(Device) User-facing device, wires PIP frontend
nimbus/driver.py NimbusDriver(HamiltonTCPHandler) TCP communication, hardware discovery
nimbus/pip_backend.py NimbusPIPBackend(PIPBackend) Pipetting operations
nimbus/commands.py 18 command classes + helpers Wire protocol command definitions
nimbus/door.py NimbusDoor Door control subsystem
nimbus/chatterbox.py NimbusChatterboxDriver Simulation driver
liquid_handlers/tcp_base.py HamiltonTCPHandler(Driver) TCP driver base class
hamilton/tcp/*.py Shared TCP protocol layer Promoted from legacy

Test plan

  • All 66 legacy Nimbus tests pass
  • All 91 legacy TCP tests pass
  • All legacy tests run through the new v1b1 code (verified via call tracing — 356 v1b1 method calls)
  • Class identity preserved across legacy/new import paths (Address is LegacyAddress)
  • Chatterbox smoke test: Nimbus(deck, chatterbox=True) setup/stop works
  • 0 pyright type errors, 0 ruff lint errors
  • Pre-commit hooks pass (ruff format, ruff check, typos)

🤖 Generated with Claude Code

rickwierenga and others added 2 commits April 4, 2026 13:36
Decomposes the monolithic legacy NimbusBackend into the three-layer v1b1
architecture matching the STAR port:

- Nimbus(Device): user-facing class, wires PIP capability frontend
- NimbusDriver(HamiltonTCPHandler): TCP communication, hardware discovery
- NimbusPIPBackend(PIPBackend): pipetting operations (pick_up/drop/asp/disp)
- NimbusDoor: door control subsystem (follows STARCover pattern)
- NimbusChatterboxDriver: simulation driver for testing without hardware

Also promotes the shared Hamilton TCP protocol layer from legacy to
pylabrobot/hamilton/tcp/ and converts legacy TCP submodules to thin
re-export shims (eliminating ~2,470 lines of duplication).

The legacy NimbusBackend is now a thin wrapper that delegates all
pipetting operations to NimbusPIPBackend and door operations to
NimbusDoor, maintaining the exact same API. All 157 legacy tests pass
and run through the new v1b1 code (verified via call tracing).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add early return for empty ops in pick_up_tips/drop_tips/aspirate/dispense
- Add channel bounds check in _fill_by_channels
- Add _ensure_deck() calls in pick_up_tips, drop_tips, _initialize_smart_roll
- Fix Nimbus.stop() guard on _setup_finished (safe double-stop)
- Fix Nimbus.setup() to clean up driver on partial failure (connection leak)
- Fix version_bite typo -> version_byte in packets.py
- Add actual logger.warning for protocol version mismatch (was silent pass)
- Fix incorrect port docstring in tcp_base.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports the legacy Hamilton Nimbus integration to the v1b1 Device/Driver/Backend architecture by extracting a shared Hamilton TCP protocol layer into pylabrobot/hamilton/tcp/ and converting the legacy TCP modules into compatibility shims, while introducing a new Nimbus driver/device stack.

Changes:

  • Promotes the Hamilton TCP protocol/packet/message/command/introspection stack into pylabrobot/hamilton/tcp/ and replaces legacy implementations with thin re-export shims.
  • Adds a reusable HamiltonTCPHandler base driver plus a new NimbusDriver, Nimbus device, NimbusPIPBackend, and door/chatterbox subsystems.
  • Updates legacy Nimbus backend tests to set up new v1b1 delegates in the legacy wrapper’s test scaffolding.

Reviewed changes

Copilot reviewed 21 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/protocol.py Replaced legacy protocol constants/enums with re-export shim to new canonical module.
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/packets.py Replaced packet structures with re-export shim to new canonical module.
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/messages.py Replaced message builders/parsers with re-export shim to new canonical module.
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/introspection.py Replaced introspection API with re-export shim to new canonical module.
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/commands.py Replaced command base class with re-export shim to new canonical module.
pylabrobot/legacy/liquid_handling/backends/hamilton/tcp/init.py Added legacy-package re-exports pointing at new canonical TCP layer.
pylabrobot/legacy/liquid_handling/backends/hamilton/nimbus_backend_tests.py Adjusted test scaffolding to initialize legacy wrapper delegates using new v1b1 components.
pylabrobot/hamilton/tcp/tests/init.py Adds test package marker for the new TCP layer.
pylabrobot/hamilton/tcp/protocol.py New canonical protocol constants/enums for Hamilton TCP instruments.
pylabrobot/hamilton/tcp/packets.py New canonical packet encode/decode structures for Hamilton TCP.
pylabrobot/hamilton/tcp/messages.py New canonical message builders/parsers and HOI parameter encoding/parsing.
pylabrobot/hamilton/tcp/introspection.py New canonical introspection API and command set for runtime discovery.
pylabrobot/hamilton/tcp/commands.py New canonical HamiltonCommand base class for the refactored stack.
pylabrobot/hamilton/tcp/init.py Public re-exports for the new Hamilton TCP protocol layer.
pylabrobot/hamilton/liquid_handlers/tcp_base.py Introduces HamiltonTCPHandler base driver implementing setup/init/registration/discovery and command execution.
pylabrobot/hamilton/liquid_handlers/nimbus/tests/init.py Adds Nimbus v1b1 test package marker.
pylabrobot/hamilton/liquid_handlers/nimbus/pip_backend.py Implements Nimbus-specific PIP backend translating PIP ops into Nimbus firmware commands.
pylabrobot/hamilton/liquid_handlers/nimbus/nimbus.py Adds user-facing Nimbus(Device) wiring driver + PIP capability.
pylabrobot/hamilton/liquid_handlers/nimbus/driver.py Adds NimbusDriver on top of HamiltonTCPHandler with Nimbus object discovery and subsystem wiring.
pylabrobot/hamilton/liquid_handlers/nimbus/door.py Adds NimbusDoor subsystem for door lock operations.
pylabrobot/hamilton/liquid_handlers/nimbus/commands.py Adds Nimbus command classes and helpers for firmware method calls.
pylabrobot/hamilton/liquid_handlers/nimbus/chatterbox.py Adds simulation driver that logs commands and returns canned responses.
pylabrobot/hamilton/liquid_handlers/nimbus/init.py Exposes Nimbus v1b1 public API surface via package exports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix string_array parser to honor count prefix (encoder was correct,
  parser was not reading the u32 count — now they match)
- Enforce per-call timeout in send_command via asyncio.wait_for
- Validate host is provided when chatterbox=False in Nimbus.__init__
- Replace type: ignore with assert in test helper for type safety

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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