Skip to content

Commit

Permalink
Do not publish interal calls to move to, fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Cox authored and Laura Cox committed May 17, 2021
1 parent aef1076 commit e0c13a4
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
38 changes: 22 additions & 16 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}')
Expand Down Expand Up @@ -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 {}'
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion api/tests/opentrons/protocol_api/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions api/tests/opentrons/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand All @@ -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'
]

Expand All @@ -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'
]

Expand Down
1 change: 1 addition & 0 deletions api/tests/opentrons/test_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]

Expand Down

0 comments on commit e0c13a4

Please sign in to comment.