AFL.automation.prepare.OT2HTTPDriver#
Functions
|
Return the ceiling of x as an Integral. |
|
Classes
|
|
|
|
|
HTTP-backed Opentrons OT-2 driver. |
|
PurePath subclass that can make system calls. |
- class AFL.automation.prepare.OT2HTTPDriver.OT2HTTPDriver(overrides=None)[source]#
HTTP-backed Opentrons OT-2 driver.
This driver wraps the Opentrons HTTP API and persists deck state in the AFL driver configuration so labware, modules, instruments, tip usage, and preparation targets can survive run recreation.
- Parameters:
overrides (dict, optional) – Configuration overrides merged into
defaultsduring driver initialization.
Notes
The driver recreates robot runs on demand and reloads previously configured deck state when a run expires or is recreated.
Examples
>>> driver = OT2HTTPDriver({"robot_ip": "192.168.1.50"}) >>> driver.load_labware("opentrons_96_tiprack_300ul", "1") >>> driver.load_instrument("p300_single", "left", ["1"]) >>> driver.transfer("2A1", "3A1", 100)
- PIPETTE_NAME_ALIASES = {'p10': 'p10_single', 'p1000': 'p1000_single', 'p1000_single': 'p1000_single', 'p10_single': 'p10_single', 'p10_single_gen1': 'p10_single', 'p300': 'p300_single', 'p300_single': 'p300_single'}#
- EXPECTED_TIPRACK_TOKEN = {'p1000_single': '1000ul', 'p10_single': '10ul', 'p300_single': '300ul'}#
- defaults = {'available_tips': {}, 'loaded_instruments': {}, 'loaded_labware': {}, 'loaded_modules': {}, 'occupied_sample_locations': [], 'prep_targets': [], 'reserved_stock_tips': [], 'robot_ip': '127.0.0.1', 'robot_port': '31950', 'stock_tip_locations': {}, 'stock_tip_reservations': {}, 'tip_rack_offset': {'x': 0, 'y': 0, 'z': 0}}#
- __init__(overrides=None)[source]#
Initialize the OT-2 HTTP driver.
- Parameters:
overrides (dict, optional) – Configuration values that override the class defaults.
Examples
>>> driver = OT2HTTPDriver({"robot_ip": "127.0.0.1", "robot_port": "31950"}) >>> driver.base_url 'http://127.0.0.1:31950'
- log_info(message)[source]#
Log an informational message.
- Parameters:
message (str) – Message to emit.
- reset_prep_targets()[source]#
Clear queued preparation targets.
Examples
>>> driver.reset_prep_targets()
- add_prep_targets(targets, reset=False)[source]#
Append preparation target locations.
- Parameters:
Examples
>>> driver.add_prep_targets(["4A1", "4A2"], reset=True)
- get_prep_target()[source]#
Pop and return the next queued preparation target.
- Returns:
Next queued target location.
- Return type:
- reset_tipracks(mount='both')[source]#
Reset available-tip tracking for one or more mounts.
- Parameters:
mount ({"left", "right", "both"}, default="both") – Mount selection to reset.
- home(**kwargs)[source]#
Home the robot’s axes using the dedicated /robot/home endpoint.
This endpoint is a direct control endpoint and doesn’t require creating a run. It can be used to home all axes at once or specific axes as needed.
- get_wells(locs)[source]#
Convert deck locations into validated HTTP API well descriptors.
- Parameters:
locs (str or sequence of str) – Deck locations in
slot+wellform, for example"1A1".- Returns:
Well descriptors containing
labwareIdandwellName.- Return type:
- Raises:
ValueError – If the slot has no loaded labware or the stored labware metadata is malformed.
AssertionError – If the requested well is not valid for the loaded labware.
- send_labware(labware_def, check_run_status=True, reload_loaded_labware=True)[source]#
Persist and upload a custom labware definition.
- Parameters:
- Returns:
Upload metadata including definition URI, version, and content hash.
- Return type:
- load_labware(name, slot, module=None, check_run_status=True, **kwargs)[source]#
Load labware into a deck slot or module.
- Parameters:
name (str) – Labware load name or
namespace/load_namekey.slot (str) – Deck slot identifier.
module (str, optional) – Module identifier when loading onto a module.
check_run_status (bool, default=True) – If
False, skip the run-status GET check when ensuring a run.**kwargs – Additional options, including
labware_jsonfor custom labware.
- Returns:
Loaded labware identifier returned by the robot.
- Return type:
- load_instrument(name, mount, tip_rack_slots, reload=False, check_run_status=True, update_pipettes=True, **kwargs)[source]#
Load a pipette and initialize tip tracking.
- Parameters:
name (str) – Pipette name or alias.
mount ({"left", "right"}) – Mount on which to load the pipette.
tip_rack_slots (sequence of str) – Slots containing compatible tipracks.
reload (bool, default=False) – If
True, preserve existing tip availability during run reload.check_run_status (bool, default=True) – If
False, skip the run-status GET check when ensuring a run.update_pipettes (bool, default=True) – If
False, skip refreshing attached pipette metadata.
- Returns:
Loaded pipette identifier returned by the robot.
- Return type:
- mix(volume, location, repetitions=1, **kwargs)[source]#
Mix liquid in place by repeated aspirate/dispense cycles.
- transfer(source, dest, volume, mix_before=None, mix_after=None, air_gap=0, aspirate_rate=None, dispense_rate=None, mix_aspirate_rate=None, mix_dispense_rate=None, blow_out=False, post_aspirate_delay=0.0, aspirate_equilibration_delay=0.0, post_dispense_delay=0.0, drop_tip=True, return_tip=False, force_new_tip=False, to_top=True, to_center=False, to_top_z_offset=0, source_z_offset=0, tip_rack_offset=None, return_tip_z_offset=None, fast_mixing=False, touch_tip=False, tip_location=None, **kwargs)[source]#
Transfer liquid between two deck locations.
- Parameters:
source (str) – Source deck location such as
"2A1".dest (str) – Destination deck location such as
"3B1".volume (float) – Requested transfer volume in microliters.
mix_before (sequence of int and float, optional) – Two-item sequence
(repetitions, volume_ul)applied before the aspirate step.mix_after (sequence of int and float, optional) – Two-item sequence
(repetitions, volume_ul)applied after the dispense step.air_gap (float, default=0) – Air gap volume in microliters.
aspirate_rate (float, optional) – Aspirate flow rate in microliters per second.
dispense_rate (float, optional) – Dispense flow rate in microliters per second.
mix_aspirate_rate (float, optional) – Aspirate flow rate used during mix cycles.
mix_dispense_rate (float, optional) – Dispense flow rate used during mix cycles.
blow_out (bool, default=False) – If
True, perform a blow-out after dispensing.post_aspirate_delay (float, default=0.0) – Delay in seconds after moving above the source well.
aspirate_equilibration_delay (float, default=0.0) – Delay in seconds while the tip remains in the source liquid after aspirating.
post_dispense_delay (float, default=0.0) – Delay in seconds after dispensing.
drop_tip (bool, default=True) – If
True, discard the tip after the transfer.return_tip (bool, default=False) – If
True, return the tip to its origin instead of discarding it.force_new_tip (bool, default=False) – If
True, force a fresh tip between split sub-transfers.to_top (bool, default=True) – Dispense at the top of the destination well.
to_center (bool, default=False) – Dispense at the center of the destination well.
to_top_z_offset (float, default=0) – Additional z-offset applied when dispensing to the top.
source_z_offset (float, default=0) – Additional z-offset applied when aspirating from the source.
tip_rack_offset (dict, optional) – Offset mapping with
x,y, andzkeys used for tip pickup and tip return.return_tip_z_offset (float, optional) – Return-only z-offset applied when returning a tip to its origin. If omitted, the existing
tip_rack_offsetz value is used.fast_mixing (bool, default=False) – Reserved flag for higher-level callers.
touch_tip (bool, default=False) – If
True, touch the tip to the destination well after dispense.tip_location (str, optional) – Explicit tip location to use, for example
"1A1".**kwargs – Additional compatibility aliases such as
blowoutandtouchTip.
- Returns:
Structured transfer metadata including selected pipette, subtransfer volumes, source and destination well metadata, and applied options.
- Return type:
- Raises:
ValueError – If the transfer request is invalid or no suitable pipette is loaded.
RuntimeError – If the underlying robot command fails.
Examples
>>> driver.transfer("2A1", "3A1", 150) >>> driver.transfer( ... "2A1", ... "3A1", ... 50, ... mix_before=(3, 40), ... return_tip=True, ... tip_rack_offset={"x": 0, "y": 0, "z": -1}, ... )
- pickup_tip(tip_location, tip_rack_offset=None)[source]#
Pick up a specific tip from a deck tip location.
- Parameters:
- Returns:
Pickup metadata including mount, pipette, and requested tip location.
- Return type:
- Raises:
ValueError – If the requested tip location is invalid or unavailable.
RuntimeError – If another tip is already attached.
- return_tip(tip_location=None, tip_rack_offset=None, return_tip_z_offset=None)[source]#
Return the currently attached tip to its original tiprack well.
- Parameters:
tip_location (str, optional) – Expected current tip location such as
"1A2". When provided, this is validated against the attached tip before returning it.tip_rack_offset (dict, optional) – Offset mapping with
x,y, andzkeys applied while moving to the return location.return_tip_z_offset (float, optional) – Return-only z-offset applied during the return operation.
- Returns:
Return metadata including the tip origin and status.
- Return type:
- Raises:
ValueError – If the requested tip location does not match the attached tip.
- set_aspirate_rate(rate=150, pipette=None)[source]#
Set stored aspirate flow rate for one or more active pipettes.
- set_dispense_rate(rate=300, pipette=None)[source]#
Set stored dispense flow rate for one or more active pipettes.
- set_gantry_speed(speed=400)[source]#
Record a requested gantry speed change.
Notes
The HTTP driver currently logs the request but does not apply it through the robot server.
- get_pipette(volume, method='min_transfers')[source]#
Select the best loaded pipette for a requested volume.
- set_tempmodule_temperature(module_id, temperature_c, hold_time=0.0, wait=True)[source]#
Set a temperature module target and optionally wait to stabilize.
- Returns:
Current and target temperatures after stabilization.
- Return type:
- deactivate_tempmodule(module_id, timeout_s=120, wait=True)[source]#
Deactivate a temperature module.
- make_align_script(filename: str)[source]#
Generate an Opentrons Python Protocol API script to verify alignment.
- Parameters:
filename (str) – Output path for the generated protocol script.
Notes
The generated script recreates the current deck state and moves each loaded pipette to the top of well
A1for each non-tiprack labware.Examples
>>> driver.make_align_script("align_check.py")