AFL.automation.prepare.OT2Prepare#

Functions

enforce_units(value, unit_type)

Ensure that a number has units and convert to the default_units

listify(obj)

Classes

Driver(name[, defaults, overrides, ...])

OT2HTTPDriver([overrides])

HTTP-backed Opentrons OT-2 driver.

OT2Prepare([overrides])

Preparation-oriented OT-2 driver.

PrepareDriver(driver_name[, overrides])

Base class for prepare drivers.

class AFL.automation.prepare.OT2Prepare.OT2Prepare(overrides=None)[source]#

Preparation-oriented OT-2 driver.

This class combines OT2HTTPDriver transport primitives with the higher-level preparation workflow implemented by PrepareDriver. It adds stock-aware tip reservation, destination occupancy tracking, and execution helpers for preparation plans.

Parameters:

overrides (dict, optional) – Configuration overrides merged into the inherited defaults.

Examples

>>> driver = OT2Prepare({"robot_ip": "192.168.1.50"})
>>> driver.add_prep_targets(["4A1", "4A2"])
>>> driver.resolve_destination(None)
'4A1'
defaults = {'catch_protocol': {}, 'catch_volume': '900 ul', 'deck': {}, 'fixed_compositions': {}, 'prep_targets': [], 'prepare_volume': '900 ul', 'stock_locations': {}, 'stock_mix_order': [], 'stock_transfer_params': {}, 'stocks': []}#
__init__(overrides=None)[source]#

Initialize the preparation driver.

Parameters:

overrides (dict, optional) – Configuration values applied on top of the inherited defaults.

Examples

>>> driver = OT2Prepare({"prepare_volume": "500 ul"})
>>> driver.last_target_location is None
True
status()[source]#

Return combined preparation and robot status lines.

Returns:

Human-readable status lines from both parent driver layers.

Return type:

list of str

Examples

>>> isinstance(driver.status(), list)
True
clear_sample_locations(locations=None)[source]#

Clear occupied sample destination tracking.

Parameters:

locations (str or sequence of str, optional) – Specific occupied locations to clear. If omitted, all occupied sample locations are cleared.

Returns:

Normalized locations that were cleared.

Return type:

list of str

Examples

>>> driver.clear_sample_locations(["4A1"])
['4A1']
>>> driver.clear_sample_locations()
[]
resolve_destination(destination)[source]#

Resolve the destination well for a preparation.

Parameters:

destination (str or None) – Explicit destination location. If None, the next queued preparation target is consumed.

Returns:

Normalized destination location.

Return type:

str

Raises:

ValueError – If no destination is available or the destination is already occupied.

Examples

>>> driver.resolve_destination("4A1")
'4A1'
execute_preparation(target, balanced_target, destination)[source]#

Execute a simple preparation protocol into one destination.

Parameters:
  • target (object) – Original target specification from the preparation workflow.

  • balanced_target (object) – Balanced target object containing a generated protocol.

  • destination (str) – Destination deck location.

Returns:

True when all transfers succeed, otherwise False.

Return type:

bool

Raises:

ValueError – If no protocol is available or a stock location cannot be resolved.

Examples

>>> driver.execute_preparation(target, balanced_target, "4A1")
True
execute_preparation_plan(target, balanced_target, destination, procedure_plan, intermediate_destinations)[source]#

Execute a staged preparation plan with intermediates.

Parameters:
  • target (object) – Original target specification.

  • balanced_target (object) – Balanced target object associated with the plan.

  • destination (str) – Final destination location.

  • procedure_plan (dict) – Staged plan containing dilution and final-mix steps.

  • intermediate_destinations (sequence of str) – Concrete deck locations assigned to intermediate stages.

Returns:

True when the plan completes successfully.

Return type:

bool

Raises:

ValueError – If the intermediate mapping is inconsistent or a stage type is unknown.

Examples

>>> driver.execute_pre preparation_plan(target, balanced_target, "4A1", plan, ["5A1"])
True
stocks_by_location(location)[source]#

Return the configured stock object at a deck location.

Parameters:

location (str) – Deck location associated with a configured stock.

Returns:

Matching stock object.

Return type:

object

Raises:

ValueError – If no stock is configured at the requested location.

build_prepare_result(feasible_result, balanced_target)[source]#

Build the serialized result payload for a preparation.

Parameters:
  • feasible_result (object) – Feasibility result from the preparation workflow.

  • balanced_target (object) – Balanced target object to serialize.

Returns:

Serialized target data with total volume included when available.

Return type:

dict

process_stocks()[source]#

Process stocks and refresh deck-derived preparation state.

Notes

This extends PrepareDriver stock processing by rebuilding the reverse deck map and stock-tip reservation state.

get_stock_inventory(stock_name=None, include_sources=True)[source]#
get_transfer_params(stock_name)[source]#

Return merged transfer parameters for a stock.

Parameters:

stock_name (str) – Stock identifier.

Returns:

Default transfer parameters overlaid with stock-specific overrides.

Return type:

dict

Examples

>>> isinstance(driver.get_transfer_params("default"), dict)
True
reorder_protocol(protocol)[source]#

Reorder protocol steps according to configured stock-name order.

Parameters:

protocol (sequence) – Protocol steps with a source attribute (or procedure-plan transfer dictionaries with source_location). A stock may have several source wells; all of those wells are ordered using the stock’s configured name.

Returns:

Reordered protocol steps.

Return type:

list

transfer_to_catch(source=None, dest=None, **kwargs)[source]#

Transfer a prepared sample into the configured catch destination.

Parameters:
  • source (str, optional) – Source location. Defaults to the last preparation destination.

  • dest (str, optional) – Destination override for the catch transfer.

  • **kwargs – Additional transfer keyword arguments merged into the configured catch protocol.

Returns:

The method raises on failure and records the transfer on success.

Return type:

None

Raises:
  • ValueError – If no source or destination can be resolved.

  • RuntimeError – If the underlying transfer fails.

load_gen1_p10(mount, tip_rack_slots, **kwargs)[source]#

Load a GEN1 P10 single-channel pipette.

Parameters:
  • mount ({"left", "right"}) – Mount on which to load the pipette.

  • tip_rack_slots (sequence of str) – Tiprack slots associated with the pipette.

  • **kwargs – Additional keyword arguments forwarded to load_instrument().

Returns:

Loaded pipette identifier returned by the robot.

Return type:

str

reset()[source]#

Reset preparation targets and stock state.

Notes

This reset is preparation-focused and delegates to PrepareDriver helpers rather than resetting the OT-2 run.