Skip to content

Commit 82a35aa

Browse files
committed
feat(api): add locationSequence to reloadLabware
1 parent 04321c6 commit 82a35aa

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

api/src/opentrons/protocol_engine/commands/reload_labware.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Reload labware command request, result, and implementation models."""
2+
23
from __future__ import annotations
34
from pydantic import BaseModel, Field
45
from typing import TYPE_CHECKING, Optional, Type
56
from typing_extensions import Literal
67

8+
from .labware_handling_common import LabwarePositionResultMixin
79
from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData
810
from ..errors.error_occurrence import ErrorOccurrence
911
from ..state.update_types import StateUpdate
@@ -24,27 +26,9 @@ class ReloadLabwareParams(BaseModel):
2426
)
2527

2628

27-
class ReloadLabwareResult(BaseModel):
29+
class ReloadLabwareResult(LabwarePositionResultMixin):
2830
"""Result data from the execution of a LoadLabware command."""
2931

30-
labwareId: str = Field(
31-
...,
32-
description="An ID to reference this labware in subsequent commands. Same as the one in the parameters.",
33-
)
34-
offsetId: Optional[str] = Field(
35-
# Default `None` instead of `...` so this field shows up as non-required in
36-
# OpenAPI. The server is allowed to omit it or make it null.
37-
None,
38-
description=(
39-
"An ID referencing the labware offset that will apply"
40-
" to the reloaded labware."
41-
" This offset will be in effect until the labware is moved"
42-
" with a `moveLabware` command."
43-
" Null or undefined means no offset applies,"
44-
" so the default of (0, 0, 0) will be used."
45-
),
46-
)
47-
4832

4933
class ReloadLabwareImplementation(
5034
AbstractCommandImpl[ReloadLabwareParams, SuccessData[ReloadLabwareResult]]
@@ -77,6 +61,9 @@ async def execute(
7761
public=ReloadLabwareResult(
7862
labwareId=params.labwareId,
7963
offsetId=reloaded_labware.offsetId,
64+
locationSequence=self._state_view.geometry.get_predicted_location_sequence(
65+
reloaded_labware.location
66+
),
8067
),
8168
state_update=state_update,
8269
)

api/tests/opentrons/protocol_engine/commands/test_reload_labware.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test load labware commands."""
2+
23
import inspect
34

45
import pytest
@@ -14,6 +15,7 @@
1415

1516
from opentrons.protocol_engine.types import (
1617
DeckSlotLocation,
18+
OnAddressableAreaLocationSequenceComponent,
1719
)
1820
from opentrons.protocol_engine.execution import ReloadedLabwareData, EquipmentHandler
1921
from opentrons.protocol_engine.resources import labware_validation
@@ -59,13 +61,29 @@ async def test_reload_labware_implementation(
5961
offsetId="labware-offset-id",
6062
)
6163
)
64+
decoy.when(
65+
state_view.geometry.get_predicted_location_sequence(
66+
DeckSlotLocation(slotName=DeckSlotName.SLOT_4)
67+
)
68+
).then_return(
69+
[
70+
OnAddressableAreaLocationSequenceComponent(
71+
addressableAreaName="4", slotName=DeckSlotName.SLOT_4
72+
)
73+
]
74+
)
6275

6376
result = await subject.execute(data)
6477

6578
assert result == SuccessData(
6679
public=ReloadLabwareResult(
6780
labwareId="my-labware-id",
6881
offsetId="labware-offset-id",
82+
locationSequence=[
83+
OnAddressableAreaLocationSequenceComponent(
84+
addressableAreaName="4", slotName=DeckSlotName.SLOT_4
85+
)
86+
],
6987
),
7088
state_update=StateUpdate(
7189
labware_location=LabwareLocationUpdate(

0 commit comments

Comments
 (0)