Skip to content

Commit

Permalink
fix(api): Add proper tip mismatch for flex (#14563)
Browse files Browse the repository at this point in the history
# Overview
Turns out we never actually updated the tiprack mismatch warning in the
python api to handle flex pipette capabilities. Adds in the proper tip
types and a test.
  • Loading branch information
Laura-Danielle authored Feb 29, 2024
1 parent 2c5932f commit d887d03
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
19 changes: 13 additions & 6 deletions api/src/opentrons/protocols/api_support/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ def tip_length_for(


VALID_PIP_TIPRACK_VOL = {
"p10": [10, 20],
"p20": [10, 20],
"p50": [50, 200, 300],
"p300": [200, 300],
"p1000": [1000],
"FLEX": {"p50": [50], "p1000": [50, 200, 1000]},
"OT2": {
"p10": [10, 20],
"p20": [10, 20],
"p50": [50, 200, 300],
"p300": [200, 300],
"p1000": [1000],
},
}


Expand All @@ -92,7 +95,11 @@ def validate_tiprack(
# tipracks to the pipette as a refactor
if tip_rack.uri.startswith("opentrons/"):
tiprack_vol = tip_rack.wells()[0].max_volume
valid_vols = VALID_PIP_TIPRACK_VOL[instrument_name.split("_")[0]]
instr_metadata = instrument_name.split("_")
gen_lookup = (
"FLEX" if ("flex" in instr_metadata or "96" in instr_metadata) else "OT2"
)
valid_vols = VALID_PIP_TIPRACK_VOL[gen_lookup][instrument_name.split("_")[0]]
if tiprack_vol not in valid_vols:
log.warning(
f"The pipette {instrument_name} and its tip rack {tip_rack.load_name}"
Expand Down
36 changes: 35 additions & 1 deletion api/tests/opentrons/protocols/api_support/test_instrument.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import pytest
import logging
from typing import Optional
from opentrons.protocol_api import ProtocolContext
from opentrons.protocols.api_support.instrument import validate_takes_liquid
from opentrons.protocols.api_support.instrument import (
validate_takes_liquid,
validate_tiprack,
)
from opentrons.types import Location, Point


Expand Down Expand Up @@ -125,3 +130,32 @@ def test_validate_takes_liquid_adapter(ctx):
reject_module=False,
reject_adapter=True,
)


@pytest.mark.parametrize(
argnames=["pipette_name", "log_value"],
argvalues=[
["p1000_96", None],
[
"p50_single_flex",
"The pipette p50_single_flex and its tip rack opentrons_flex_96_tiprack_200ul appear to be mismatched. Please check your protocol.",
],
[
"p20_single_gen2",
"The pipette p20_single_gen2 and its tip rack opentrons_flex_96_tiprack_200ul appear to be mismatched. Please check your protocol.",
],
],
)
def test_validate_tiprack(
ctx: ProtocolContext, caplog, pipette_name: str, log_value: Optional[str]
):
tip_rack = ctx.load_labware("opentrons_flex_96_tiprack_200ul", 2)

with caplog.at_level(logging.WARNING):
log = logging.getLogger(__name__)
validate_tiprack(pipette_name, tip_rack, log=log)

if log_value:
assert caplog.messages[0] == log_value
else:
assert caplog.records == []

0 comments on commit d887d03

Please sign in to comment.