Deck API

PR here - deck server/client over a remote API by Koeng101 · Pull Request #896 · PyLabRobot/pylabrobot · GitHub

Adds the a remote deck over http / gRPC.

server:

# server.py
import uvicorn
from pylabrobot.resources import Cor_96_wellplate_360ul_Fb, hamilton_96_tiprack_1000uL_filter
from pylabrobot.resources.hamilton import STARDeck
from pylabrobot.resources.remote.server import create_app

deck = STARDeck()
deck.assign_child_resource(hamilton_96_tiprack_1000uL_filter(name="tips"), rails=3)
deck.assign_child_resource(Cor_96_wellplate_360ul_Fb(name="plate"), rails=9)

app = create_app(deck)
uvicorn.run(app, host="0.0.0.0", port=8080)

client:

# client.py
import asyncio
from pylabrobot.liquid_handling import LiquidHandler
from pylabrobot.liquid_handling.backends import STARBackend
from pylabrobot.resources.remote.client import RemoteDeck

deck = RemoteDeck.connect("http://localhost:8080")
lh = LiquidHandler(backend=STARBackend(), deck=deck)
await lh.setup()

tips = deck.get_resource("tips")
plate = deck.get_resource("plate")
await lh.pick_up_tips(tips["A1:H1"])
await lh.aspirate(plate["A1:H1"], vols=[100.0] * 8)
await lh.dispense(plate["A2:H2"], vols=[100.0] * 8)
await lh.drop_tips(tips["A1:H1"])

One thing I’m thinking about adding is some way to coordinate many bots. Like maybe I’ll also need to connect with RemoteDeck.connect("``http://localhost:8080/STAR_1``"). Any thoughts?

Serializing to disk is not yet implemented, but relatively simple: just need to implement that behind the API and ensure API compliance.

One thing I will note: buf lint calls a bunch of errors, as RPC requests (traditionally) are only used in a single place; ie, every endpoint has a unique endpoint, request, and response. This is so you can transition easily when you add or remove fields of an API. For this, might not be a problem - but is probably something to have an opinion about for plr