From e0c13a4fa6aa59c4d9b095a9f66731c0f156bcc8 Mon Sep 17 00:00:00 2001 From: Laura Cox Date: Mon, 17 May 2021 14:21:07 -0400 Subject: [PATCH] Do not publish interal calls to move to, fix some tests --- .../protocol_api/instrument_context.py | 38 +++++++++++-------- .../protocol_api/paired_instrument_context.py | 1 + .../opentrons/protocol_api/test_context.py | 2 +- api/tests/opentrons/test_execute.py | 5 +++ api/tests/opentrons/test_simulate.py | 1 + 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/api/src/opentrons/protocol_api/instrument_context.py b/api/src/opentrons/protocol_api/instrument_context.py index 9f4f75986e7..7b954596b65 100644 --- a/api/src/opentrons/protocol_api/instrument_context.py +++ b/api/src/opentrons/protocol_api/instrument_context.py @@ -191,7 +191,8 @@ def aspirate(self, if self.api_version < APIVersion(2, 3) or \ not self._implementation.is_ready_to_aspirate(): if dest.labware.is_well: - self.move_to(dest.labware.as_well().top()) + self.move_to(dest.labware.as_well().top(), + publish=False) else: # TODO(seth,2019/7/29): This should be a warning exposed # via rpc to the runapp @@ -202,9 +203,9 @@ def aspirate(self, "cause over aspiration if the previous command is a " "blow_out.") self._implementation.prepare_for_aspirate() - self.move_to(dest) + self.move_to(dest, publish=False) elif dest != self._ctx.location_cache: - self.move_to(dest) + self.move_to(dest, publish=False) c_vol = self._implementation.get_available_volume() \ if not volume else volume @@ -271,10 +272,10 @@ def dispense(self, else: loc = location.bottom().move( types.Point(0, 0, self.well_bottom_clearance.dispense)) - self.move_to(loc) + self.move_to(loc, publish=False) elif isinstance(location, types.Location): loc = location - self.move_to(location) + self.move_to(location, publish=False) elif location is not None: raise TypeError( f'location should be a Well or Location, but it is {location}') @@ -393,10 +394,10 @@ def blow_out(self, self._log.warning('Blow_out being performed on a tiprack. ' 'Please re-check your code') loc = location.top() - self.move_to(loc) + self.move_to(loc, publish=False) elif isinstance(location, types.Location): loc = location - self.move_to(loc) + self.move_to(loc, publish=False) elif location is not None: raise TypeError( 'location should be a Well or Location, but it is {}' @@ -496,7 +497,7 @@ def touch_tip(self, move_with_z_offset =\ well.as_well().top().point + types.Point(0, 0, v_offset) to_loc = types.Location(move_with_z_offset, well) - self.move_to(to_loc) + self.move_to(to_loc, publish=False) else: raise TypeError( 'location should be a Well, but it is {}'.format(location)) @@ -554,7 +555,7 @@ def air_gap(self, if not loc or not loc.labware.is_well: raise RuntimeError('No previous Well cached to perform air gap') target = loc.labware.as_well().top(height) - self.move_to(target) + self.move_to(target, publish=False) self.aspirate(volume) return self @@ -660,7 +661,7 @@ def pick_up_tip( do_publish(self.broker, cmds.pick_up_tip, self.pick_up_tip, 'before', None, None, self, location=target) - self.move_to(target.top()) + self.move_to(target.top(), publish=False) self._implementation.pick_up_tip( well=target._impl, @@ -780,7 +781,7 @@ def drop_tip( " However, it is a {}".format(location)) do_publish(self.broker, cmds.drop_tip, self.drop_tip, 'before', None, None, self, location=target) - self.move_to(target) + self.move_to(target, publish=False) self._implementation.drop_tip(home_after=home_after) do_publish(self.broker, cmds.drop_tip, self.drop_tip, @@ -1086,7 +1087,8 @@ def move_to(self, location: types.Location, force_direct: bool = False, minimum_z_height: Optional[float] = None, - speed: Optional[float] = None + speed: Optional[float] = None, + publish: bool = True ) -> InstrumentContext: """ Move the instrument. @@ -1101,6 +1103,8 @@ def move_to(self, the straight linear speed of the motion; to limit individual axis speeds, you can use :py:attr:`.ProtocolContext.max_speeds`. + :param publish: Whether a call to this function should publish to the + runlog or not. """ from_loc = self._ctx.location_cache if not from_loc: @@ -1110,16 +1114,18 @@ def move_to(self, if isinstance(mod, ThermocyclerContext): mod.flag_unsafe_move(to_loc=location, from_loc=from_loc) - do_publish(self.broker, cmds.move_to, self.move_to, 'before', - None, None, self, location or self._ctx.location_cache) + if publish: + do_publish(self.broker, cmds.move_to, self.move_to, 'before', + None, None, self, location or self._ctx.location_cache) self._implementation.move_to( location=location, force_direct=force_direct, minimum_z_height=minimum_z_height, speed=speed ) - do_publish(self.broker, cmds.move_to, self.move_to, 'after', - None, None, self, location or self._ctx.location_cache) + if publish: + do_publish(self.broker, cmds.move_to, self.move_to, 'after', + None, None, self, location or self._ctx.location_cache) return self @property # type: ignore diff --git a/api/src/opentrons/protocol_api/paired_instrument_context.py b/api/src/opentrons/protocol_api/paired_instrument_context.py index c7790fb3e4a..70f00e6ea0e 100644 --- a/api/src/opentrons/protocol_api/paired_instrument_context.py +++ b/api/src/opentrons/protocol_api/paired_instrument_context.py @@ -812,6 +812,7 @@ def move_to(self, location: types.Location, force_direct: bool = False, locations: Optional[List] = None if location: locations = self._get_locations(location) + publish_paired(self.broker, cmds.paired_move_to, 'before', None, instruments, locations) self.paired_instrument_obj.move_to( diff --git a/api/tests/opentrons/protocol_api/test_context.py b/api/tests/opentrons/protocol_api/test_context.py index 88540d39ac5..2576a1212ed 100644 --- a/api/tests/opentrons/protocol_api/test_context.py +++ b/api/tests/opentrons/protocol_api/test_context.py @@ -703,7 +703,7 @@ def test_blow_out(ctx, monkeypatch): instr.pick_up_tip() instr.aspirate(10, lw.wells()[0]) - def fake_move(loc): + def fake_move(loc, publish): nonlocal move_location move_location = loc diff --git a/api/tests/opentrons/test_execute.py b/api/tests/opentrons/test_execute.py index 6151bee0152..59a24ea2f69 100644 --- a/api/tests/opentrons/test_execute.py +++ b/api/tests/opentrons/test_execute.py @@ -80,6 +80,7 @@ def emit_runlog(entry): 'Dispensing 4.5 uL into B1 of Dest Plate on 3 at 2.5 uL/sec', 'Touching tip', 'Blowing out at B1 of Dest Plate on 3', + 'Moving to 5', 'Dropping tip into A1 of Trash on 12' ] @@ -106,6 +107,7 @@ def emit_runlog(entry): 'Dispensing 4.5 uL into B1 of Dest Plate on 3 at 2.5 uL/sec', 'Touching tip', 'Blowing out at B1 of Dest Plate on 3', + 'Moving to 5', 'Dropping tip into A1 of Trash on 12' ] @@ -132,6 +134,9 @@ def emit_runlog(entry): 'Dispensing 4.5 uL into B1 of Dest Plate on 3 at 2.5 uL/sec', 'Touching tip', 'Blowing out at B1 of Dest Plate on 3', + 'Moving to 5', + 'Moving to B2 of Dest Plate on 3', + 'Moving to B2 of Dest Plate on 3', 'Dropping tip into A1 of Trash on 12' ] diff --git a/api/tests/opentrons/test_simulate.py b/api/tests/opentrons/test_simulate.py index e0e028a9798..ad5ea10c765 100644 --- a/api/tests/opentrons/test_simulate.py +++ b/api/tests/opentrons/test_simulate.py @@ -41,6 +41,7 @@ def test_simulate_function_json_apiv2(get_json_protocol_fixture): 'Dispensing 4.5 uL into B1 of Dest Plate on 3 at 2.5 uL/sec', 'Touching tip', 'Blowing out at B1 of Dest Plate on 3', + 'Moving to 5', 'Dropping tip into A1 of Trash on 12' ]