From e666bad08eeb7ce37501e3e632fddd177d8ae1d7 Mon Sep 17 00:00:00 2001 From: Ryan Howard Date: Mon, 11 Dec 2023 13:57:04 -0500 Subject: [PATCH] fix(hardware-testing): remove gravimetric patches (#14152) * override the pipette guards at runtime instead of with a patch * remove the api patch for gravimetric tests * format/lint --- .../hardware_testing/gravimetric/helpers.py | 31 ++++++++++++++++--- .../gravimetric/overrides/api.patch | 28 ----------------- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/hardware-testing/hardware_testing/gravimetric/helpers.py b/hardware-testing/hardware_testing/gravimetric/helpers.py index 02c56125da18..57199fd67413 100644 --- a/hardware-testing/hardware_testing/gravimetric/helpers.py +++ b/hardware-testing/hardware_testing/gravimetric/helpers.py @@ -210,6 +210,30 @@ def _check_if_software_supports_high_volumes() -> bool: return modified_a and modified_b +def _override_set_current_volume(self, new_volume: float) -> None: # noqa: ANN001 + assert new_volume >= 0 + # assert new_volume <= self.working_volume + self._current_volume = new_volume + + +def _override_add_current_volume(self, volume_incr: float) -> None: # noqa: ANN001 + self._current_volume += volume_incr + + +def _override_ok_to_add_volume(self, volume_incr: float) -> bool: # noqa: ANN001 + return True + + +def _override_software_supports_high_volumes() -> None: + # yea so ok this is pretty ugly but this is super helpful for us + # with this we don't need to apply patches, and can run the testing scripts + # without pushing modified code to the robot + + Pipette.set_current_volume = _override_set_current_volume # type: ignore[assignment] + Pipette.ok_to_add_volume = _override_ok_to_add_volume # type: ignore[assignment] + Pipette.add_current_volume = _override_add_current_volume # type: ignore[assignment] + + def _get_channel_offset(cfg: config.VolumetricConfig, channel: int) -> Point: assert ( channel < cfg.pipette_channels @@ -327,11 +351,8 @@ def _get_volumes( kind, channels, pipette_volume, tip_volume, extra ) if not _check_if_software_supports_high_volumes(): - if ctx.is_simulating(): - test_volumes = _reduce_volumes_to_not_exceed_software_limit( - test_volumes, pipette_volume, channels, tip_volume - ) - else: + _override_software_supports_high_volumes() + if not _check_if_software_supports_high_volumes(): raise RuntimeError("you are not the correct branch") return test_volumes diff --git a/hardware-testing/hardware_testing/gravimetric/overrides/api.patch b/hardware-testing/hardware_testing/gravimetric/overrides/api.patch index 32fd9e25e7c2..e69de29bb2d1 100644 --- a/hardware-testing/hardware_testing/gravimetric/overrides/api.patch +++ b/hardware-testing/hardware_testing/gravimetric/overrides/api.patch @@ -1,28 +0,0 @@ -diff --git a/api/src/opentrons/hardware_control/instruments/ot3/pipette.py b/api/src/opentrons/hardware_control/instruments/ot3/pipette.py -index 1f6dd0b4b5..1d0cb7b7e3 100644 ---- a/api/src/opentrons/hardware_control/instruments/ot3/pipette.py -+++ b/api/src/opentrons/hardware_control/instruments/ot3/pipette.py -@@ -432,11 +432,11 @@ class Pipette(AbstractInstrument[PipetteConfigurations]): - - def set_current_volume(self, new_volume: float) -> None: - assert new_volume >= 0 -- assert new_volume <= self.working_volume -+ # assert new_volume <= self.working_volume - self._current_volume = new_volume - - def add_current_volume(self, volume_incr: float) -> None: -- assert self.ok_to_add_volume(volume_incr) -+ # assert self.ok_to_add_volume(volume_incr) - self._current_volume += volume_incr - - def remove_current_volume(self, volume_incr: float) -> None: -@@ -444,7 +444,8 @@ class Pipette(AbstractInstrument[PipetteConfigurations]): - self._current_volume -= volume_incr - - def ok_to_add_volume(self, volume_incr: float) -> bool: -- return self.current_volume + volume_incr <= self.working_volume -+ # return self.current_volume + volume_incr <= self.working_volume -+ return True - - def ok_to_push_out(self, push_out_dist_mm: float) -> bool: - return push_out_dist_mm <= (