Skip to content

Commit

Permalink
initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Dec 20, 2024
1 parent 9b2de59 commit 5057c7f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
47 changes: 39 additions & 8 deletions api/src/opentrons/protocol_api/core/engine/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
NozzleLayoutConfigurationType,
AddressableOffsetVector,
LiquidClassRecord,
NextTipInfo,
NoTipAvailable,
)
from opentrons.protocol_engine.errors.exceptions import TipNotAttachedError
from opentrons.protocol_engine.clients import SyncClient as EngineClient
Expand All @@ -45,6 +47,7 @@
from . import transfer_components_executor as tx_comps_executor

from .well import WellCore
from .labware import LabwareCore
from ..instrument import AbstractInstrument
from ...disposal_locations import TrashBin, WasteChute

Expand Down Expand Up @@ -898,9 +901,16 @@ def load_liquid_class(
)
return result.liquidClassId

# TODO: update with getNextTip implementation
def get_next_tip(self) -> None:
def get_next_tip(self, tip_racks: List[LabwareCore], starting_well: Optional[str]) -> NextTipInfo:
"""Get the next tip to pick up."""
next_tip_info = self._engine_client.execute_command_without_recovery(
cmd.GetNextTipParams(
pipetteId=self._pipette_id,
labwareIds=[tip_rack.labware_id for tip_rack in tip_racks],
startingTipWell=starting_well,
)
)
return next_tip_info

def transfer_liquid(
self,
Expand All @@ -909,7 +919,7 @@ def transfer_liquid(
source: List[Tuple[Location, WellCore]],
dest: List[Tuple[Location, WellCore]],
new_tip: TransferTipPolicyV2,
tiprack_uri: str,
tip_racks: List[LabwareCore],
trash_location: Union[Location, TrashBin, WasteChute],
) -> None:
"""Execute transfer using liquid class properties.
Expand All @@ -929,6 +939,9 @@ def transfer_liquid(
tip_drop_location: Location where the tip will be dropped (if appropriate).
"""
# This function is WIP
# TODO: Validate all tipracks in this list have the same uri
tiprack_uri = tip_racks[0].get_uri()

# TODO: use the ID returned by load_liquid_class in command annotations
self.load_liquid_class(
liquid_class=liquid_class,
Expand All @@ -953,14 +966,32 @@ def transfer_liquid(
max_volume=self.get_max_volume(),
)
if new_tip == TransferTipPolicyV2.ONCE:
# TODO: update this once getNextTip is implemented
self.get_next_tip()
next_tip = self.get_next_tip(
tip_racks=tip_racks,
starting_well=None,
)
if isinstance(next_tip, NoTipAvailable):
raise RuntimeError(
f"No tip available among {tip_racks} for this transfer."
)
tiprack_id, starting_tip = next_tip
self.pick_up_tip() # TODO: figure out what to do about Location

for step_volume, (src, dest) in source_dest_per_volume_step: # type: ignore[assignment]
# TODO: check for PER_SOURCE tip policy
if new_tip == TransferTipPolicyV2.ALWAYS:
# TODO: update this once getNextTip is implemented
self.get_next_tip()
next_tip = self.get_next_tip(
tip_racks=tip_racks,
starting_well=None,
)
if isinstance(next_tip, NoTipAvailable):
raise RuntimeError(
f"No tip available among {tip_racks} for this transfer."
)
tiprack_id, starting_tip = next_tip
self.pick_up_tip() # TODO: figure out what to do about Location


# TODO: add aspirate and dispense

if new_tip == TransferTipPolicyV2.ALWAYS:
if isinstance(trash_location, (TrashBin, WasteChute)):
Expand Down
3 changes: 2 additions & 1 deletion api/src/opentrons/protocol_api/core/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from opentrons.protocol_api._liquid import LiquidClass
from ..disposal_locations import TrashBin, WasteChute
from .well import WellCoreType
from .labware import LabwareCoreType


class AbstractInstrument(ABC, Generic[WellCoreType]):
Expand Down Expand Up @@ -318,7 +319,7 @@ def transfer_liquid(
source: List[Tuple[types.Location, WellCoreType]],
dest: List[Tuple[types.Location, WellCoreType]],
new_tip: TransferTipPolicyV2,
tiprack_uri: str,
tipracks: List[LabwareCoreType],
trash_location: Union[types.Location, TrashBin, WasteChute],
) -> None:
"""Transfer a liquid from source to dest according to liquid class properties."""
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ def transfer_liquid(
for well in flat_dests_list
],
new_tip=valid_new_tip,
tiprack_uri=tiprack.uri,
tipracks=[rack._core for rack in self._tip_racks],
trash_location=checked_trash_location,
)
return self
Expand Down

0 comments on commit 5057c7f

Please sign in to comment.