Skip to content

Commit

Permalink
fix more linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Nov 3, 2024
1 parent efee8b1 commit 5fa07d7
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 22 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ def api_version(self) -> APIVersion:
return self._api_version

@property
@requires_version(2, 21)
@requires_version(2, 22)
def robot(self) -> RobotContext:
"""The :py:class:`.RobotContext` for the protocol.
:meta private:
"""
if self._core.robot_type != "OT-3 Standard" or not self._robot:
raise RobotTypeError("The RobotContext is only available on Flex robot.")
raise RobotTypeError("The RobotContext is only available on Flex robots.")
return self._robot

@property
Expand Down
8 changes: 4 additions & 4 deletions api/src/opentrons/protocol_api/robot_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
self._api_version = api_version

@property
@requires_version(2, 21)
@requires_version(2, 22)
def api_version(self) -> APIVersion:
return self._api_version

Expand All @@ -67,7 +67,7 @@ def hardware(self) -> HardwareManager:
# context commands.
return self._hardware

@requires_version(2, 21)
@requires_version(2, 22)
def move_to(
self,
mount: Union[Mount, str],
Expand All @@ -88,7 +88,7 @@ def move_to(
mount = validation.ensure_instrument_mount(mount)
self._core.move_to(mount, destination.point, speed)

@requires_version(2, 21)
@requires_version(2, 22)
def move_axes_to(
self,
axis_map: Union[AxisMapType, StringAxisMap],
Expand Down Expand Up @@ -120,7 +120,7 @@ def move_axes_to(
critical_point = None
self._core.move_axes_to(axis_map, critical_point, speed)

@requires_version(2, 21)
@requires_version(2, 22)
def move_axes_relative(
self,
axis_map: Union[AxisMapType, StringAxisMap],
Expand Down
12 changes: 5 additions & 7 deletions api/src/opentrons/protocol_engine/execution/gantry_mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
MotorAxis.RIGHT_PLUNGER: HardwareAxis.C,
MotorAxis.EXTENSION_Z: HardwareAxis.Z_G,
MotorAxis.EXTENSION_JAW: HardwareAxis.G,
MotorAxis.CLAMP_JAW_96_CHANNEL: HardwareAxis.Q,
MotorAxis.AXIS_96_CHANNEL_CAM: HardwareAxis.Q,
}

_MOTOR_AXIS_TO_HARDWARE_MOUNT: Dict[MotorAxis, Mount] = {
Expand Down Expand Up @@ -61,7 +61,7 @@
HardwareAxis.Z_R: MotorAxis.RIGHT_Z,
HardwareAxis.Z_G: MotorAxis.EXTENSION_Z,
HardwareAxis.G: MotorAxis.EXTENSION_JAW,
HardwareAxis.Q: MotorAxis.CLAMP_JAW_96_CHANNEL,
HardwareAxis.Q: MotorAxis.AXIS_96_CHANNEL_CAM,
}

# The height of the bottom of the pipette nozzle at home position without any tips.
Expand Down Expand Up @@ -328,7 +328,7 @@ async def move_axes(
axis_map: The mapping of axes to command.
critical_point: A critical point override for axes
speed: Optional speed parameter for the move.
relative_move: Specifying whether a relative move needs to be handled or not.
relative_move: Whether the axis map needs to be converted from a relative to absolute move.
"""
try:
pos_hw = self._convert_axis_map_for_hw(axis_map)
Expand Down Expand Up @@ -544,10 +544,8 @@ def get_max_travel_z_from_mount(self, mount: MountType) -> float:
"""Get the maximum allowed z-height for mount."""
pipette = self._state_view.pipettes.get_by_mount(mount)
if self._state_view.config.robot_type == "OT-2 Standard":
instrument_height = (
self._state_view.pipettes.get_instrument_max_height_ot2(pipette.id)
if pipette
else VIRTUAL_MAX_OT3_HEIGHT
instrument_height = self._state_view.pipettes.get_instrument_max_height_ot2(
pipette.id
)
else:
instrument_height = VIRTUAL_MAX_OT3_HEIGHT
Expand Down
1 change: 1 addition & 0 deletions api/src/opentrons/protocol_engine/execution/movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ async def move_to_well(
async def move_mount_to(
self, mount: MountType, destination: DeckPoint, speed: Optional[float] = None
) -> Point:
"""Move mount to a specific location on the deck."""
hw_mount = mount.to_hw_mount()
await self._gantry_mover.prepare_for_mount_movement(hw_mount)
origin = await self._gantry_mover.get_position_from_mount(mount=hw_mount)
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class MotorAxis(str, Enum):
RIGHT_PLUNGER = "rightPlunger"
EXTENSION_Z = "extensionZ"
EXTENSION_JAW = "extensionJaw"
CLAMP_JAW_96_CHANNEL = "clampJaw96Channel"
AXIS_96_CHANNEL_CAM = "axis96ChannelCam"


# TODO(mc, 2022-01-18): use opentrons_shared_data.module.types.ModuleModel
Expand Down
3 changes: 2 additions & 1 deletion api/src/opentrons/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def ot2_axes(cls) -> List["AxisType"]:
]

@classmethod
def ot3_gantry_axes(cls) -> List["AxisType"]:
def flex_gantry_axes(cls) -> List["AxisType"]:
return [
AxisType.X,
AxisType.Y,
Expand All @@ -316,6 +316,7 @@ def ot2_gantry_axes(cls) -> List["AxisType"]:
AxisMapType = Dict[AxisType, float]
StringAxisMap = Dict[str, float]


# TODO(mc, 2020-11-09): this makes sense in shared-data or other common
# model library
# https://github.com/Opentrons/opentrons/pull/6943#discussion_r519029833
Expand Down
2 changes: 2 additions & 0 deletions api/tests/opentrons/protocol_api/test_robot_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Test the functionality of the `RobotContext`."""
import pytest
from decoy import Decoy
from typing import Union, Optional
Expand Down Expand Up @@ -32,6 +33,7 @@ def api_version() -> APIVersion:

@pytest.fixture
def mock_deck(decoy: Decoy) -> Deck:
"""Get a mocked deck object."""
deck = decoy.mock(cls=Deck)
decoy.when(deck.get_slot_center(DeckSlotName.SLOT_D1.value)).then_return(
Point(3, 3, 3)
Expand Down
3 changes: 3 additions & 0 deletions api/tests/opentrons/protocol_api/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ def test_ensure_axis_map_type_success(
is_96_channel: bool,
expected_axis_map: AxisMapType,
) -> None:
"""Check that axis map type validation returns the correct shape."""
res = subject.ensure_axis_map_type(axis_map, robot_type, is_96_channel)
assert res == expected_axis_map

Expand Down Expand Up @@ -634,6 +635,7 @@ def test_ensure_axis_map_type_failure(
is_96_channel: bool,
error_message: str,
) -> None:
"""Check that axis_map validation occurs for the given scenarios."""
with pytest.raises(subject.IncorrectAxisError, match=error_message):
subject.ensure_axis_map_type(axis_map, robot_type, is_96_channel)

Expand All @@ -656,5 +658,6 @@ def test_ensure_axis_map_type_failure(
def test_ensure_only_gantry_axis_map_type(
axis_map: AxisMapType, robot_type: RobotType, error_message: str
) -> None:
"""Check that gantry axis_map validation occurs for the given scenarios."""
with pytest.raises(subject.IncorrectAxisError, match=error_message):
subject.ensure_only_gantry_axis_map_type(axis_map, robot_type)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for Robot Module commands."""
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ async def test_home_z(
},
],
[
{MotorAxis.CLAMP_JAW_96_CHANNEL: 10.0},
{MotorAxis.AXIS_96_CHANNEL_CAM: 10.0},
None,
False,
Mount.LEFT,
Expand All @@ -522,6 +522,7 @@ async def test_move_axes(
call_to_hw: "OrderedDict[HardwareAxis, float]",
final_position: Dict[HardwareAxis, float],
) -> None:
"""Test the move axes function."""
subject = HardwareGantryMover(
state_view=mock_state_view, hardware_api=ot3_hardware_api
)
Expand Down Expand Up @@ -690,10 +691,10 @@ async def test_virtual_move_to(
{MotorAxis.X: 0.0, MotorAxis.Y: 0.0, MotorAxis.RIGHT_Z: 20},
],
[
{MotorAxis.CLAMP_JAW_96_CHANNEL: 10},
{MotorAxis.AXIS_96_CHANNEL_CAM: 10},
None,
False,
{MotorAxis.CLAMP_JAW_96_CHANNEL: 10},
{MotorAxis.AXIS_96_CHANNEL_CAM: 10},
],
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,12 @@ async def move_tip_motor_relative_ot3(
raise RuntimeError("No pipette found on LEFT mount")

current_gear_pos = api._backend.gear_motor_position or 0.0
target_pos = {Axis.Q: current_gear_pos + distance}
target_pos = current_gear_pos + distance

if speed is not None and distance < 0:
speed *= -1

_move_coro = api._backend.tip_action(
current_gear_pos, [(target_pos, speed or 400)]
)
_move_coro = api._backend.tip_action(current_gear_pos, [(target_pos, speed or 400)])
if motor_current is None:
await _move_coro
else:
Expand Down

0 comments on commit 5fa07d7

Please sign in to comment.