Skip to content

Commit

Permalink
require request to get schema 3 default version
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 9, 2025
1 parent fa268d0 commit 6b59349
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
18 changes: 15 additions & 3 deletions api/src/opentrons/protocol_api/core/engine/load_labware_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def resolve(
namespace: Optional[str],
version: Optional[int],
custom_load_labware_params: List[LabwareLoadParams],
api_level: Optional[Tuple[int, int]] = None,
schema_version: Optional[int] = 2,
) -> Tuple[str, int]:
"""Resolve the load labware parameters that best matches any custom labware, or default to opentrons standards
Expand All @@ -89,6 +91,8 @@ def resolve(
version: Optionally provided labware definition version
custom_load_labware_params: List of load labware parameters associated with custom labware that
match given parameters
api_level: Current api level.
schema_version: The desired labware schema version to draw a definition from.
Returns:
A tuple of the resolved namespace and version
Expand All @@ -115,10 +119,16 @@ def matches_params(custom_params: LabwareLoadParams) -> bool:
# custom labware matching that namespace, so we will always take this path in
# that case.
resolved_namespace = namespace if namespace is not None else OPENTRONS_NAMESPACE
api_level = api_level if api_level else (2, 14)
schema_version = schema_version if schema_version else 2
resolved_version = (
version
if version is not None
else _get_default_version_for_standard_labware(load_name=load_name)
else _get_default_version_for_standard_labware(
load_name=load_name,
current_api_level=api_level,
schema_version=schema_version,
)
)

elif len(filtered_custom_params) > 1:
Expand All @@ -136,11 +146,13 @@ def matches_params(custom_params: LabwareLoadParams) -> bool:


def _get_default_version_for_standard_labware(
load_name: str, api_level: Tuple[int, int] = (2, 14)
load_name: str,
current_api_level: Tuple[int, int] = (2, 14),
schema_version: int = 2,
) -> int:
# We know the protocol is running at least apiLevel 2.14 by this point because
# apiLevel 2.13 and below has its own separate code path for resolving labware.
if api_level >= (2, 21):
if current_api_level >= (2, 21) and schema_version == 3:
found_version = _APILEVEL_2_21_OT_DEFAULT_VERSIONS.get(load_name, None)
if found_version:
return found_version
Expand Down
10 changes: 8 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
version: Optional[int] = None,
schema: Optional[int] = 2,
) -> LabwareCore:
"""Load a labware using its identifying parameters."""
load_location = self._convert_labware_location(location=location)
Expand All @@ -219,7 +220,12 @@ def load_labware(
self._engine_client.state.labware.find_custom_labware_load_params()
)
namespace, version = load_labware_params.resolve(
load_name, namespace, version, custom_labware_params
load_name,
namespace,
version,
custom_labware_params,
self._api_version,
schema,
)

load_result = self._engine_client.execute_command_without_recovery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
version: Optional[int] = None,
schema: Optional[int] = 2,
) -> LegacyLabwareCore:
"""Load a labware using its identifying parameters."""
if isinstance(location, OffDeckType):
Expand Down
3 changes: 2 additions & 1 deletion api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int],
version: Optional[int] = None,
schema: Optional[int] = 2,
) -> LabwareCoreType:
"""Load a labware using its identifying parameters."""
...
Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_api/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def load_labware(
lid: Optional[str] = None,
namespace: Optional[str] = None,
version: Optional[int] = None,
schema: Optional[int] = None,
) -> Labware:
"""Load a compatible labware onto the labware using its load parameters.
Expand All @@ -563,6 +564,7 @@ def load_labware(
namespace=namespace,
version=version,
location=self._core,
schema=schema,
)

labware = Labware(
Expand Down

0 comments on commit 6b59349

Please sign in to comment.