Skip to content

Commit 56af170

Browse files
authored
chore(api): load new evotips labware on api >= 2.23 (#17749)
Loads the new adapter defs from #17675 by default on api versions about 2.23. Tested by simulating the protocol from that PR and making sure the correct version gets loaded on 2.23 and the old one gets loaded (well, the protocol fails because the old version doesn't have stacking offsets for the new variants, which is proof enough) on 2.22.
1 parent 1965cf8 commit 56af170

File tree

8 files changed

+91
-19
lines changed

8 files changed

+91
-19
lines changed

api/src/opentrons/protocol_api/core/engine/load_labware_params.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from opentrons.protocols.api_support.constants import OPENTRONS_NAMESPACE
44
from opentrons.protocol_engine.state.labware import LabwareLoadParams
5+
from opentrons.protocols.api_support.types import APIVersion
56

67

78
# Default versions of Opentrons standard labware definitions in Python Protocol API
@@ -34,6 +35,11 @@
3435
"corning_24_wellplate_3.4ml_flat": 2,
3536
}
3637

38+
_APILEVEL_2_23_OT_DEFAULT_VERSIONS: Dict[str, int] = {
39+
"evotips_opentrons_96_labware": 2,
40+
"evotips_flex_96_tiprack_adapter": 2,
41+
}
42+
3743

3844
class AmbiguousLoadLabwareParamsError(RuntimeError):
3945
"""Error raised when specific labware parameters cannot be found due to multiple matching labware definitions."""
@@ -44,6 +50,7 @@ def resolve(
4450
namespace: Optional[str],
4551
version: Optional[int],
4652
custom_load_labware_params: List[LabwareLoadParams],
53+
api_version: APIVersion,
4754
) -> Tuple[str, int]:
4855
"""Resolve the load labware parameters that best matches any custom labware, or default to opentrons standards
4956
@@ -82,7 +89,9 @@ def matches_params(custom_params: LabwareLoadParams) -> bool:
8289
resolved_version = (
8390
version
8491
if version is not None
85-
else _get_default_version_for_standard_labware(load_name=load_name)
92+
else _get_default_version_for_standard_labware(
93+
load_name=load_name, api_version=api_version
94+
)
8695
)
8796

8897
elif len(filtered_custom_params) > 1:
@@ -99,7 +108,15 @@ def matches_params(custom_params: LabwareLoadParams) -> bool:
99108
return resolved_namespace, resolved_version
100109

101110

102-
def _get_default_version_for_standard_labware(load_name: str) -> int:
111+
def _get_default_version_for_standard_labware(
112+
load_name: str, api_version: APIVersion
113+
) -> int:
103114
# We know the protocol is running at least apiLevel 2.14 by this point because
104115
# apiLevel 2.13 and below has its own separate code path for resolving labware.
105-
return _APILEVEL_2_14_OT_DEFAULT_VERSIONS.get(load_name, 1)
116+
if (
117+
api_version >= APIVersion(2, 23)
118+
and load_name in _APILEVEL_2_23_OT_DEFAULT_VERSIONS
119+
):
120+
return _APILEVEL_2_23_OT_DEFAULT_VERSIONS[load_name]
121+
else:
122+
return _APILEVEL_2_14_OT_DEFAULT_VERSIONS.get(load_name, 1)

api/src/opentrons/protocol_api/core/engine/module_core.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,11 @@ def set_stored_labware(
759759
)
760760

761761
main_namespace, main_version = load_labware_params.resolve(
762-
main_load_name, main_namespace, main_version, custom_labware_params
762+
main_load_name,
763+
main_namespace,
764+
main_version,
765+
custom_labware_params,
766+
self._api_version,
763767
)
764768
main_labware = cmd.flex_stacker.StackerStoredLabwareDetails(
765769
loadName=main_load_name, namespace=main_namespace, version=main_version
@@ -769,7 +773,11 @@ def set_stored_labware(
769773

770774
if lid_load_name:
771775
lid_namespace, lid_version = load_labware_params.resolve(
772-
lid_load_name, lid_namespace, lid_version, custom_labware_params
776+
lid_load_name,
777+
lid_namespace,
778+
lid_version,
779+
custom_labware_params,
780+
self._api_version,
773781
)
774782
lid_labware = cmd.flex_stacker.StackerStoredLabwareDetails(
775783
loadName=lid_load_name, namespace=lid_namespace, version=lid_version
@@ -783,6 +791,7 @@ def set_stored_labware(
783791
adapter_namespace,
784792
adapter_version,
785793
custom_labware_params,
794+
self._api_version,
786795
)
787796
adapter_labware = cmd.flex_stacker.StackerStoredLabwareDetails(
788797
loadName=adapter_load_name,

api/src/opentrons/protocol_api/core/engine/protocol.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""ProtocolEngine-based Protocol API core implementation."""
2+
23
from __future__ import annotations
34
from typing import Dict, Optional, Type, Union, List, Tuple, TYPE_CHECKING
45

@@ -224,7 +225,7 @@ def load_labware(
224225
self._engine_client.state.labware.find_custom_labware_load_params()
225226
)
226227
namespace, version = load_labware_params.resolve(
227-
load_name, namespace, version, custom_labware_params
228+
load_name, namespace, version, custom_labware_params, self._api_version
228229
)
229230

230231
load_result = self._engine_client.execute_command_without_recovery(
@@ -295,7 +296,7 @@ def load_adapter(
295296
self._engine_client.state.labware.find_custom_labware_load_params()
296297
)
297298
namespace, version = load_labware_params.resolve(
298-
load_name, namespace, version, custom_labware_params
299+
load_name, namespace, version, custom_labware_params, self._api_version
299300
)
300301
load_result = self._engine_client.execute_command_without_recovery(
301302
cmd.LoadLabwareParams(
@@ -343,7 +344,7 @@ def load_lid(
343344
self._engine_client.state.labware.find_custom_labware_load_params()
344345
)
345346
namespace, version = load_labware_params.resolve(
346-
load_name, namespace, version, custom_labware_params
347+
load_name, namespace, version, custom_labware_params, self._api_version
347348
)
348349
load_result = self._engine_client.execute_command_without_recovery(
349350
cmd.LoadLidParams(
@@ -960,7 +961,7 @@ def load_lid_stack(
960961
self._engine_client.state.labware.find_custom_labware_load_params()
961962
)
962963
namespace, version = load_labware_params.resolve(
963-
load_name, namespace, version, custom_labware_params
964+
load_name, namespace, version, custom_labware_params, self._api_version
964965
)
965966

966967
load_result = self._engine_client.execute_command_without_recovery(
@@ -1162,7 +1163,7 @@ def _get_non_stacked_location(
11621163
OffDeckType,
11631164
WasteChute,
11641165
TrashBin,
1165-
]
1166+
],
11661167
) -> NonStackedLocation:
11671168
if isinstance(location, (ModuleCore, NonConnectedModuleCore)):
11681169
return ModuleLocation(moduleId=location.module_id)

api/tests/opentrons/protocol_api/core/engine/test_flex_stacker_core.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,29 @@ def test_set_stored_labware_all_elements(
8181
).then_return(sentinel.custom_labware_load_params)
8282
decoy.when(
8383
load_labware_params.resolve(
84-
"main-name", "main-namespace", 1, sentinel.custom_labware_load_params
84+
"main-name",
85+
"main-namespace",
86+
1,
87+
sentinel.custom_labware_load_params,
88+
MAX_SUPPORTED_VERSION,
8589
)
8690
).then_return(("main-namespace-verified", 10))
8791
decoy.when(
8892
load_labware_params.resolve(
89-
"adapter-name", "adapter-namespace", 2, sentinel.custom_labware_load_params
93+
"adapter-name",
94+
"adapter-namespace",
95+
2,
96+
sentinel.custom_labware_load_params,
97+
MAX_SUPPORTED_VERSION,
9098
)
9199
).then_return(("adapter-namespace-verified", 20))
92100
decoy.when(
93101
load_labware_params.resolve(
94-
"lid-name", "lid-namespace", 3, sentinel.custom_labware_load_params
102+
"lid-name",
103+
"lid-namespace",
104+
3,
105+
sentinel.custom_labware_load_params,
106+
MAX_SUPPORTED_VERSION,
95107
)
96108
).then_return(("lid-namespace-verified", 30))
97109

@@ -139,7 +151,11 @@ def test_set_stored_labware_only_checks_load_name_for_lid_and_adapter_valid(
139151
).then_return(sentinel.custom_labware_load_params)
140152
decoy.when(
141153
load_labware_params.resolve(
142-
"main-name", "main-namespace", 1, sentinel.custom_labware_load_params
154+
"main-name",
155+
"main-namespace",
156+
1,
157+
sentinel.custom_labware_load_params,
158+
MAX_SUPPORTED_VERSION,
143159
)
144160
).then_return(("main-namespace-verified", 10))
145161

api/tests/opentrons/protocol_api/core/engine/test_load_labware_params.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Tests for Protocol API engine parameter validation."""
2+
23
import pytest
34
from typing import List, Optional
45

56
from opentrons.protocol_api.core.engine import load_labware_params as subject
67
from opentrons.protocol_engine.state.labware import LabwareLoadParams
78
from opentrons.protocols.api_support.constants import OPENTRONS_NAMESPACE
9+
from opentrons.protocols.api_support.types import APIVersion
810

911

1012
@pytest.mark.parametrize(
@@ -15,12 +17,13 @@
1517
"custom_labware_params",
1618
"expected_namespace",
1719
"expected_version",
20+
"current_api_version",
1821
],
1922
argvalues=[
20-
("hello", "world", 123, [], "world", 123),
21-
("hello", "world", None, [], "world", 1),
22-
("hello", None, 123, [], OPENTRONS_NAMESPACE, 123),
23-
("hello", None, None, [], OPENTRONS_NAMESPACE, 1),
23+
("hello", "world", 123, [], "world", 123, APIVersion(2, 15)),
24+
("hello", "world", None, [], "world", 1, APIVersion(2, 22)),
25+
("hello", None, 123, [], OPENTRONS_NAMESPACE, 123, APIVersion(2, 14)),
26+
("hello", None, None, [], OPENTRONS_NAMESPACE, 1, APIVersion(2, 16)),
2427
(
2528
"hello",
2629
"world",
@@ -31,6 +34,7 @@
3134
],
3235
"world",
3336
123,
37+
APIVersion(2, 17),
3438
),
3539
(
3640
"hello",
@@ -42,6 +46,7 @@
4246
],
4347
"world",
4448
123,
49+
APIVersion(2, 19),
4550
),
4651
(
4752
"hello",
@@ -53,6 +58,7 @@
5358
],
5459
"world",
5560
123,
61+
APIVersion(2, 21),
5662
),
5763
],
5864
)
@@ -63,9 +69,12 @@ def test_resolve_load_labware_params(
6369
custom_labware_params: List[LabwareLoadParams],
6470
expected_namespace: str,
6571
expected_version: int,
72+
current_api_version: APIVersion,
6673
) -> None:
6774
"""It should get a namespace and version based on custom labware available or defaults."""
68-
result = subject.resolve(load_name, namespace, version, custom_labware_params)
75+
result = subject.resolve(
76+
load_name, namespace, version, custom_labware_params, current_api_version
77+
)
6978

7079
assert result == (expected_namespace, expected_version)
7180

@@ -82,6 +91,8 @@ def test_resolve_load_labware_params(
8291
"nest_96_wellplate_2ml_deep",
8392
"opentrons_96_wellplate_200ul_pcr_full_skirt",
8493
"biorad_96_wellplate_200ul_pcr",
94+
"evotips_opentrons_96_labware",
95+
"evotips_flex_96_tiprack_adapter",
8596
],
8697
)
8798
@pytest.mark.parametrize("namespace", [OPENTRONS_NAMESPACE, None])
@@ -107,6 +118,7 @@ def test_version_two_and_above_default_versioning(
107118
namespace=namespace,
108119
version=version,
109120
custom_load_labware_params=[],
121+
api_version=APIVersion(2, 23),
110122
)
111123
assert result == (OPENTRONS_NAMESPACE, expected_version)
112124

@@ -122,4 +134,5 @@ def test_resolve_load_labware_params_raises() -> None:
122134
LabwareLoadParams("hello", "world", 123),
123135
LabwareLoadParams("hello", "world", 456),
124136
],
137+
api_version=APIVersion(2, 23),
125138
)

api/tests/opentrons/protocol_api/core/engine/test_protocol_core.py

+10
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def test_load_labware(
347347
"a_namespace",
348348
456,
349349
[EngineLabwareLoadParams("hello", "world", 654)],
350+
subject.api_version,
350351
)
351352
).then_return(("some_namespace", 9001))
352353

@@ -421,6 +422,7 @@ def test_load_labware_on_staging_slot(
421422
"a_namespace",
422423
456,
423424
[EngineLabwareLoadParams("hello", "world", 654)],
425+
subject.api_version,
424426
)
425427
).then_return(("some_namespace", 9001))
426428

@@ -498,6 +500,7 @@ def test_load_labware_on_labware(
498500
"a_namespace",
499501
456,
500502
[EngineLabwareLoadParams("hello", "world", 654)],
503+
subject.api_version,
501504
)
502505
).then_return(("some_namespace", 9001))
503506

@@ -568,6 +571,7 @@ def test_load_labware_off_deck(
568571
"a_namespace",
569572
456,
570573
[EngineLabwareLoadParams("hello", "world", 654)],
574+
subject.api_version,
571575
)
572576
).then_return(("some_namespace", 9001))
573577

@@ -632,6 +636,7 @@ def test_load_adapter(
632636
"a_namespace",
633637
456,
634638
[EngineLabwareLoadParams("hello", "world", 654)],
639+
subject.api_version,
635640
)
636641
).then_return(("some_namespace", 9001))
637642

@@ -704,6 +709,7 @@ def test_load_adapter_on_staging_slot(
704709
"a_namespace",
705710
456,
706711
[EngineLabwareLoadParams("hello", "world", 654)],
712+
subject.api_version,
707713
)
708714
).then_return(("some_namespace", 9001))
709715

@@ -778,6 +784,7 @@ def test_load_lid(
778784
"a_namespace",
779785
456,
780786
[EngineLabwareLoadParams("hello", "world", 654)],
787+
subject.api_version,
781788
)
782789
).then_return(("some_namespace", 9001))
783790

@@ -849,6 +856,7 @@ def test_load_lid_stack(
849856
"a_namespace",
850857
456,
851858
[EngineLabwareLoadParams("hello", "world", 654)],
859+
subject.api_version,
852860
)
853861
).then_return(("some_namespace", 9001))
854862

@@ -1193,6 +1201,7 @@ def test_load_labware_on_module(
11931201
"a_namespace",
11941202
456,
11951203
[EngineLabwareLoadParams("hello", "world", 654)],
1204+
subject.api_version,
11961205
)
11971206
).then_return(("some_namespace", 9001))
11981207

@@ -1270,6 +1279,7 @@ def test_load_labware_on_non_connected_module(
12701279
"a_namespace",
12711280
456,
12721281
[EngineLabwareLoadParams("hello", "world", 654)],
1282+
subject.api_version,
12731283
)
12741284
).then_return(("some_namespace", 9001))
12751285

app/src/local-resources/labware/hooks/useAllLabware.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type { LabwareSort, LabwareFilter, LabwareDefAndDate } from '../types'
88
const LABWARE_LOADNAME_BLOCKLIST = [
99
'evotips_flex_96_tiprack_adapter',
1010
'evotips_opentrons_96_labware',
11+
'evotips_tiprack_adapter',
12+
'evotips_reservoir_adapter',
1113
]
1214

1315
export function useAllLabware(

shared-data/js/getLabware.ts

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export const LABWAREV2_DO_NOT_LIST = [
4747
// temporarily blocking evotips until it is out of beta
4848
'evotips_flex_96_tiprack_adapter',
4949
'evotips_opentrons_96_labware',
50+
'evotips_tiprack_adapter',
51+
'evotips_reservoir_adapter',
5052
// temporarily blocking tiprack lids until stacker launches
5153
'opentrons_flex_tiprack_lid',
5254
// temporarily blocking 20 uL Flex tip racks until they launch
@@ -71,6 +73,8 @@ export const PD_DO_NOT_LIST = [
7173
// temporarily blocking evotips until it is supported in PD
7274
'evotips_flex_96_tiprack_adapter',
7375
'evotips_opentrons_96_labware',
76+
'evotips_tiprack_adapter',
77+
'evotips_reservoir_adapter',
7478
// temporarily blocking tiprack lids until stacker launches
7579
'opentrons_flex_tiprack_lid',
7680
// temporarily blocking 20 uL Flex tip racks until they launch

0 commit comments

Comments
 (0)