diff --git a/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py b/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py index 2eaec14d627..e4485b9c974 100644 --- a/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py +++ b/hardware-testing/hardware_testing/opentrons_api/helpers_ot3.py @@ -41,6 +41,8 @@ TIP_LENGTH_OVERLAP = 10.5 TIP_LENGTH_LOOKUP = {50: 57.9, 200: 58.35, 1000: 95.6} +RESET_DELAY_SECONDS = 2 + @dataclass class CalibrationSquare: @@ -128,6 +130,8 @@ async def update_firmware( api: OT3API, force: bool = False, subsystems: Optional[List[SubSystem]] = None ) -> None: """Update firmware of OT3.""" + if not api.is_simulator: + await asyncio.sleep(RESET_DELAY_SECONDS) subsystems_on_boot = api.attached_subsystems progress_tracker: Dict[SubSystem, List[int]] = {} @@ -150,6 +154,14 @@ def _print_update_progress() -> None: _print_update_progress() +async def reset_api(api: OT3API) -> None: + """Reset OT3API.""" + if not api.is_simulator: + await asyncio.sleep(RESET_DELAY_SECONDS) + await api.cache_instruments() + await api.refresh_positions() + + async def build_async_ot3_hardware_api( is_simulating: Optional[bool] = False, use_defaults: Optional[bool] = True, @@ -192,13 +204,10 @@ async def build_async_ot3_hardware_api( print(e) kwargs["use_usb_bus"] = False # type: ignore[assignment] api = await builder(loop=loop, **kwargs) # type: ignore[arg-type] - if not is_simulating: - await asyncio.sleep(0.5) if not is_simulating: await update_firmware(api) print(f"Firmware: v{api.fw_version}") - await api.cache_instruments() - await api.refresh_positions() + await reset_api(api) return api diff --git a/hardware-testing/hardware_testing/production_qc/firmware_check.py b/hardware-testing/hardware_testing/production_qc/firmware_check.py index e17306d4eb9..f84f5eb386c 100644 --- a/hardware-testing/hardware_testing/production_qc/firmware_check.py +++ b/hardware-testing/hardware_testing/production_qc/firmware_check.py @@ -1,5 +1,5 @@ """Firmware Check.""" -from asyncio import run, sleep +from asyncio import run from typing import List from opentrons.hardware_control.ot3api import OT3API @@ -13,10 +13,12 @@ def _get_instrument_serial_number(api: OT3API, subsystem: SubSystem) -> str: if subsystem == SubSystem.pipette_right: _pip = api.hardware_pipettes[OT3Mount.RIGHT.to_mount()] + assert _pip _pip_id = helpers_ot3.get_pipette_serial_ot3(_pip) _id = f" ({_pip_id})" elif subsystem == SubSystem.pipette_left: _pip = api.hardware_pipettes[OT3Mount.LEFT.to_mount()] + assert _pip _pip_id = helpers_ot3.get_pipette_serial_ot3(_pip) _id = f" ({_pip_id})" elif subsystem == SubSystem.gripper: @@ -32,7 +34,6 @@ def _get_instrument_serial_number(api: OT3API, subsystem: SubSystem) -> str: async def _main(simulate: bool, subsystems: List[SubSystem]) -> None: api = await helpers_ot3.build_async_ot3_hardware_api(is_simulating=simulate) while True: - await api.cache_instruments() for subsys, state in api.attached_subsystems.items(): _id = _get_instrument_serial_number(api, subsys) print(f" - v{state.current_fw_version}: {subsys.name}{_id}") @@ -42,8 +43,7 @@ async def _main(simulate: bool, subsystems: List[SubSystem]) -> None: print("done") if api.is_simulator: break - else: - await sleep(1) + await helpers_ot3.reset_api(api) if __name__ == "__main__": diff --git a/hardware-testing/hardware_testing/production_qc/pipette_assembly_qc_ot3/__main__.py b/hardware-testing/hardware_testing/production_qc/pipette_assembly_qc_ot3/__main__.py index 9788332f1aa..ce2e9fd21fe 100644 --- a/hardware-testing/hardware_testing/production_qc/pipette_assembly_qc_ot3/__main__.py +++ b/hardware-testing/hardware_testing/production_qc/pipette_assembly_qc_ot3/__main__.py @@ -1294,7 +1294,7 @@ def _listener(message: MessageDefinition, arb_id: ArbitrationId) -> None: return test_pass -async def _main(test_config: TestConfig) -> None: +async def _main(test_config: TestConfig) -> None: # noqa: C901 global IDEAL_LABWARE_LOCATIONS global CALIBRATED_LABWARE_LOCATIONS global FINAL_TEST_RESULTS @@ -1567,9 +1567,7 @@ async def _main(test_config: TestConfig) -> None: arg_parser.add_argument( "--slot-reservoir", type=int, default=DEFAULT_SLOT_RESERVOIR ) - arg_parser.add_argument( - "--slot-plate", type=int, default=DEFAULT_SLOT_PLATE - ) + arg_parser.add_argument("--slot-plate", type=int, default=DEFAULT_SLOT_PLATE) arg_parser.add_argument("--slot-fixture", type=int, default=DEFAULT_SLOT_FIXTURE) arg_parser.add_argument("--slot-trash", type=int, default=DEFAULT_SLOT_TRASH) arg_parser.add_argument("--simulate", action="store_true")