Skip to content

Commit

Permalink
feat(api): add locationSequence to reloadLabware
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Feb 4, 2025
1 parent 04321c6 commit 82a35aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
25 changes: 6 additions & 19 deletions api/src/opentrons/protocol_engine/commands/reload_labware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Reload labware command request, result, and implementation models."""

from __future__ import annotations
from pydantic import BaseModel, Field
from typing import TYPE_CHECKING, Optional, Type
from typing_extensions import Literal

from .labware_handling_common import LabwarePositionResultMixin
from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData
from ..errors.error_occurrence import ErrorOccurrence
from ..state.update_types import StateUpdate
Expand All @@ -24,27 +26,9 @@ class ReloadLabwareParams(BaseModel):
)


class ReloadLabwareResult(BaseModel):
class ReloadLabwareResult(LabwarePositionResultMixin):
"""Result data from the execution of a LoadLabware command."""

labwareId: str = Field(
...,
description="An ID to reference this labware in subsequent commands. Same as the one in the parameters.",
)
offsetId: Optional[str] = Field(
# Default `None` instead of `...` so this field shows up as non-required in
# OpenAPI. The server is allowed to omit it or make it null.
None,
description=(
"An ID referencing the labware offset that will apply"
" to the reloaded labware."
" This offset will be in effect until the labware is moved"
" with a `moveLabware` command."
" Null or undefined means no offset applies,"
" so the default of (0, 0, 0) will be used."
),
)


class ReloadLabwareImplementation(
AbstractCommandImpl[ReloadLabwareParams, SuccessData[ReloadLabwareResult]]
Expand Down Expand Up @@ -77,6 +61,9 @@ async def execute(
public=ReloadLabwareResult(
labwareId=params.labwareId,
offsetId=reloaded_labware.offsetId,
locationSequence=self._state_view.geometry.get_predicted_location_sequence(
reloaded_labware.location
),
),
state_update=state_update,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test load labware commands."""

import inspect

import pytest
Expand All @@ -14,6 +15,7 @@

from opentrons.protocol_engine.types import (
DeckSlotLocation,
OnAddressableAreaLocationSequenceComponent,
)
from opentrons.protocol_engine.execution import ReloadedLabwareData, EquipmentHandler
from opentrons.protocol_engine.resources import labware_validation
Expand Down Expand Up @@ -59,13 +61,29 @@ async def test_reload_labware_implementation(
offsetId="labware-offset-id",
)
)
decoy.when(
state_view.geometry.get_predicted_location_sequence(
DeckSlotLocation(slotName=DeckSlotName.SLOT_4)
)
).then_return(
[
OnAddressableAreaLocationSequenceComponent(
addressableAreaName="4", slotName=DeckSlotName.SLOT_4
)
]
)

result = await subject.execute(data)

assert result == SuccessData(
public=ReloadLabwareResult(
labwareId="my-labware-id",
offsetId="labware-offset-id",
locationSequence=[
OnAddressableAreaLocationSequenceComponent(
addressableAreaName="4", slotName=DeckSlotName.SLOT_4
)
],
),
state_update=StateUpdate(
labware_location=LabwareLocationUpdate(
Expand Down

0 comments on commit 82a35aa

Please sign in to comment.