From c65dc75ffd4f77202e25d6c0a46c614ce051c091 Mon Sep 17 00:00:00 2001 From: Max Marrone Date: Thu, 17 Oct 2024 12:44:00 -0400 Subject: [PATCH] Implement drop_tip()'s state updates in terms of other public methods, where possible. This is not intended to have any behavioral change. The goal of this is to make it easier for callers (i.e. Protocol Engine) to see what they have to do in order to replicate the total effect of drop_tip(). And to make it easier for human code reviewers to confirm that that's done correctly. --- api/src/opentrons/hardware_control/api.py | 9 +++++++-- api/src/opentrons/hardware_control/ot3api.py | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/src/opentrons/hardware_control/api.py b/api/src/opentrons/hardware_control/api.py index b1c0411b900..636ad165983 100644 --- a/api/src/opentrons/hardware_control/api.py +++ b/api/src/opentrons/hardware_control/api.py @@ -1277,10 +1277,15 @@ async def drop_tip(self, mount: top_types.Mount, home_after: bool = True) -> Non """Drop tip at the current location.""" await self.tip_drop_moves(mount, home_after) + # todo(mm, 2024-10-17): Ideally, callers would be able to replicate the behavior + # of this method via self.drop_tip_moves() plus other public methods. This + # currently prevents that: there is no public equivalent for + # instrument.set_current_volume(). instrument = self.get_pipette(mount) instrument.set_current_volume(0) - instrument.current_tiprack_diameter = 0.0 - instrument.remove_tip() + + self.set_current_tiprack_diameter(mount, 0.0) + await self.remove_tip(mount) async def create_simulating_module( self, diff --git a/api/src/opentrons/hardware_control/ot3api.py b/api/src/opentrons/hardware_control/ot3api.py index 8d1d8c4b6a1..52be73119a3 100644 --- a/api/src/opentrons/hardware_control/ot3api.py +++ b/api/src/opentrons/hardware_control/ot3api.py @@ -2323,14 +2323,19 @@ async def drop_tip( self, mount: Union[top_types.Mount, OT3Mount], home_after: bool = False ) -> None: """Drop tip at the current location.""" + await self.tip_drop_moves(mount=mount, home_after=home_after) + + # todo(mm, 2024-10-17): Ideally, callers would be able to replicate the behavior + # of this method via self.drop_tip_moves() plus other public methods. This + # currently prevents that: there is no public equivalent for + # instrument.set_current_volume(). realmount = OT3Mount.from_mount(mount) instrument = self._pipette_handler.get_pipette(realmount) + instrument.set_current_volume(0) - await self.tip_drop_moves(mount=mount, home_after=home_after) + self.set_current_tiprack_diameter(mount, 0.0) + await self.remove_tip(mount) - instrument.set_current_volume(0) - instrument.current_tiprack_diameter = 0.0 - instrument.remove_tip() # call this in case we're simulating: if isinstance(self._backend, OT3Simulator): self._backend._update_tip_state(realmount, False)