Writing robot agnostic methods#

This document describes best practices for writing methods that are agnostic to the robot backend.

This is a work in progress. Please contribute!

Keeping the layout separate from the protocol#

It is recommended to keep the layout of the deck separate from the protocol. This allows you to easily change the layout of the deck without having to change the protocol.

from pylabrobot.liquid_handling import LiquidHandler, STAR
from pylabrobot.resources import Deck, TipRack, Plate

# Write a method that creates a deck and defines its layout.
def make_deck() -> Deck:
  deck = Deck()


  return deck

# Instantiate the liquid handler using a deck and backend.
deck = make_deck()
backend = STAR()
lh = LiquidHandler(backend=backend, deck=deck)

# Get references to the resources you need. Use type hinting for autocompletion.
tip_rack: TipRack = lh.get_resource('tip_rack')
plate: Plate = lh.get_resource('plate')

# the protocol...

Strictness checking#

Strictness checking is a feature that allows you to specify how strictly you want the LiquidHandler to enforce the protocol. The following levels are available:

  • IGNORE: The LiquidHandler will raise an exception if you are doing something that is not legal on the robot.

  • WARN: The default. The LiquidHandler will warn you if you are doing something that is not recommended, but will not stop you from doing it.

  • STRICT: The LiquidHandler will silently log on the debug level if you are doing something that is not legal on the robot.

You can set the strictness level for the entire protocol using pylabrobot.liquid_handling.strictness.set_strictness().

from pylabrobot.liquid_handling import Strictness, set_strictness

lh.pick_up_tips(my_tip_rack["A1"], illegal_argument=True) # will log on debug level

lh.pick_up_tips(my_tip_rack["A1"], illegal_argument=True) # will warn

lh.pick_up_tips(my_tip_rack["A1"], illegal_argument=True) # will raise a TypeError