Skip to content

Commit

Permalink
chore: fix hardware-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Sep 5, 2024
1 parent 5a781f1 commit bab482b
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 237 deletions.
2 changes: 1 addition & 1 deletion hardware-testing/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ atomicwrites = "==1.4.1"
colorama = "==0.4.4"
pytest = "==7.1.1"
pytest-cov = "==2.10.1"
mypy = "==0.981"
mypy = "==1.11.0"
black = "==22.3.0"
flake8 = "~=3.9.0"
flake8-annotations = "~=2.6.2"
Expand Down
664 changes: 443 additions & 221 deletions hardware-testing/Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hardware-testing/hardware_testing/drivers/asair_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import codecs
import logging
import time
from typing import Tuple
from typing import Tuple, Optional
from abc import ABC
from dataclasses import dataclass
from . import list_ports_and_select
Expand Down Expand Up @@ -42,7 +42,7 @@
class AsairSensorError(Exception):
"""Asair sensor error."""

def __init__(self, ret_code: str = None) -> None:
def __init__(self, ret_code: Optional[str] = None) -> None:
"""Constructor."""
super().__init__(ret_code)

Expand Down
18 changes: 14 additions & 4 deletions hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
from math import pi
from subprocess import run, Popen
from time import time
from typing import Callable, Coroutine, Dict, List, Optional, Tuple, Union, cast
from typing import (
Callable,
Coroutine,
Dict,
List,
Optional,
Tuple,
Union,
cast,
Sequence,
)
import atexit
from opentrons_hardware.drivers.can_bus import DriverSettings, build, CanMessenger
from opentrons_hardware.drivers.can_bus import settings as can_bus_settings
Expand Down Expand Up @@ -138,7 +148,7 @@ def _create_attached_instruments_dict(


async def update_firmware(
api: OT3API, force: bool = False, subsystems: Optional[List[SubSystem]] = None
api: OT3API, force: bool = False, subsystems: Optional[Sequence[SubSystem]] = None
) -> None:
"""Update firmware of OT3."""
if not api.is_simulator:
Expand Down Expand Up @@ -1009,13 +1019,13 @@ def set_pipette_offset_ot3(api: OT3API, mount: OT3Mount, offset: Point) -> None:

def get_gripper_offset_ot3(api: OT3API) -> Point:
"""Get gripper offset OT3."""
assert api.has_gripper, "No gripper found"
assert api.has_gripper(), "No gripper found"
return api._gripper_handler._gripper._calibration_offset.offset # type: ignore[union-attr]


def set_gripper_offset_ot3(api: OT3API, offset: Point) -> None:
"""Set gripper offset OT3."""
assert api.has_gripper, "No gripper found"
assert api.has_gripper(), "No gripper found"
api._gripper_handler._gripper._calibration_offset.offset = offset # type: ignore[union-attr]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,4 @@ def overwrite_attached_pipette_ul_per_mm(
pipette: Optional[Pipette] = api._pipette_handler._attached_instruments[mount]
if pipette is None:
raise RuntimeError(f"No pipette is attached to mount: {mount}")
pipette._config = replace(pipette._config, ul_per_mm=ul_per_mm)
pipette._config = replace(pipette._config, ul_per_mm=ul_per_mm) # type: ignore[type-var]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Firmware Check."""
from asyncio import run
from typing import List
from typing import Sequence

from opentrons.hardware_control.ot3api import OT3API

Expand Down Expand Up @@ -31,7 +31,7 @@ def _get_instrument_serial_number(api: OT3API, subsystem: SubSystem) -> str:
return _id


async def _main(simulate: bool, subsystems: List[SubSystem]) -> None:
async def _main(simulate: bool, subsystems: Sequence[SubSystem]) -> None:
api = await helpers_ot3.build_async_ot3_hardware_api(is_simulating=simulate)
while True:
for subsys, state in api.attached_subsystems.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ async def run(api: OT3API, report: CSVReport, section: str) -> None:
await _test_wifi(report, section)
else:
report(section, "wifi", ["", "", "0.0.0.0", CSVResult.PASS])
assert nmcli.iface_info
assert nmcli.configure
assert nmcli.wifi_disconnect
assert nmcli.iface_info # type: ignore[truthy-function]
assert nmcli.configure # type: ignore[truthy-function]
assert nmcli.wifi_disconnect # type: ignore[truthy-function]

# USB-B-REAR
ui.print_header("USB-B-REAR")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def build_csv_lines() -> List[Union[CSVLine, CSVLineRepeating]]:
for t, d in PIPETTE_TESTS.items():
for m in ["left", "right"]:
tests.append(CSVLine(f"{m}-{t}", d)) # type: ignore[arg-type]
for t, d in GRIPPER_TESTS.items():
for t, d in GRIPPER_TESTS.items(): # type: ignore[assignment]
tests.append(CSVLine(f"gripper-{t}", d)) # type: ignore[arg-type]
return tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
async def _get_ip(api: OT3API) -> Optional[str]:
_ip: Optional[str] = None
if api.is_simulator:
assert nmcli.iface_info
assert nmcli.iface_info # type: ignore[truthy-function]
_ip = "127.0.0.1"
else:
ethernet_status = await nmcli.iface_info(nmcli.NETWORK_IFACES.ETH_LL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def _move_and_interrupt_with_signal(api: OT3API, sig_name: str) -> None:
runner = MoveGroupRunner(move_groups=[[_move_group_nsync]])
if api.is_simulator:
# test that the required functionality exists
assert runner.run
assert runner.run # type: ignore[truthy-function]
else:
backend: OT3Controller = api._backend # type: ignore[assignment]
messenger = backend._messenger
Expand Down
1 change: 1 addition & 0 deletions hardware-testing/mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[mypy]
show_error_codes = True
plugins = pydantic.mypy
strict = False

[mypy-can.*]
Expand Down

0 comments on commit bab482b

Please sign in to comment.