Skip to content

Commit

Permalink
use old data when not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Sep 17, 2024
1 parent 74397f2 commit 6cac1c8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
13 changes: 11 additions & 2 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Union,
)

from opentrons.protocol_engine.state.update_types import _NoChangeEnum
from opentrons_shared_data.deck.types import DeckDefinitionV5
from opentrons_shared_data.gripper.constants import LABWARE_GRIP_FORCE
from opentrons_shared_data.labware.labware_definition import LabwareRole
Expand Down Expand Up @@ -247,11 +248,19 @@ def _add_loaded_labware(self, action: Action) -> None:
action.state_update.loaded_labware.labware_id
] = LoadedLabware.construct(
id=action.state_update.loaded_labware.labware_id,
location=action.state_update.labware_location.new_location,
location=action.state_update.labware_location.new_location
if action.state_update.labware_location != _NoChangeEnum.NO_CHANGE
else self._state.labware_by_id[
action.state_update.loaded_labware.labware_id
].location,
loadName=action.state_update.loaded_labware.definition.parameters.loadName,
definitionUri=definition_uri,
offsetId=action.state_update.loaded_labware.offsetId,
displayName=action.state_update.labware_location.display_name,
displayName=action.state_update.labware_location.display_name
if action.state_update.labware_location != _NoChangeEnum.NO_CHANGE
else self._state.labware_by_id[
action.state_update.loaded_labware.labware_id
].displayName,
)


Expand Down
33 changes: 24 additions & 9 deletions api/tests/opentrons/protocol_engine/state/test_labware_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,23 @@ def test_handles_load_labware(
created_at=datetime(year=2021, month=1, day=2),
)
)
subject.handle_action(SucceedCommandAction(private_result=None, command=command, state_update=update_types.StateUpdate(
subject.handle_action(
SucceedCommandAction(
private_result=None,
command=command,
state_update=update_types.StateUpdate(
labware_location=update_types.LabwareLocationUpdate(
labware_id="test-labware-id",
display_name="display-name",
new_location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
),
loaded_labware=LoadedLabwareData(labware_id="test-labware-id", definition=well_plate_def, offsetId="offset-id")
))
loaded_labware=LoadedLabwareData(
labware_id="test-labware-id",
definition=well_plate_def,
offsetId="offset-id",
),
),
)
)

assert subject.state.labware_by_id["test-labware-id"] == expected_labware_data
Expand Down Expand Up @@ -242,14 +251,20 @@ def test_handles_move_labware(
)
)
subject.handle_action(
SucceedCommandAction(private_result=None, command=load_labware_command, state_update=update_types.StateUpdate(
SucceedCommandAction(
private_result=None,
command=load_labware_command,
state_update=update_types.StateUpdate(
labware_location=update_types.LabwareLocationUpdate(
labware_id="my-labware-id",
display_name="display-name",
new_location=LabwareOffsetLocation(slotName=DeckSlotName.SLOT_1),
new_location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
),
loaded_labware=LoadedLabwareData(
labware_id="my-labware-id", definition=well_plate_def, offsetId=None
),
loaded_labware=LoadedLabwareData(labware_id="my-labware-id", definition=well_plate_def, offsetId=None)
))
),
)
)

move_command = create_move_labware_command(
Expand Down Expand Up @@ -297,10 +312,10 @@ def test_handles_move_labware_off_deck(
private_result=None,
command=load_labware_command,
state_update=update_types.StateUpdate(
pipette_location=update_types.LabwareLocationUpdate(
labware_location=update_types.LabwareLocationUpdate(
labware_id="my-labware-id",
display_name="display-name",
new_location=LabwareOffsetLocation(slotName=DeckSlotName.SLOT_1),
new_location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
)
),
)
Expand Down

0 comments on commit 6cac1c8

Please sign in to comment.