Skip to content

Commit 939d9d8

Browse files
committed
update abstract methods and take logic out of try/except clause
1 parent acfa921 commit 939d9d8

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

api/src/opentrons/drivers/thermocycler/driver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ async def _get_limit_switch_status(self) -> None:
210210

211211
async def check_lid_status_for_real_this_time(self) -> ThermocyclerLidStatus:
212212
limit_switch_status = await self._get_limit_switch_status()
213-
raise Exception(limit_switch_status)
214-
lid_is_closed = utils.parse_key_values(value=limit_switch_status)["C"] == 1
215-
lid_is_open = utils.parse_key_values(value=limit_switch_status)["O"] == 1
213+
lid_is_closed = utils.parse_key_values(value=limit_switch_status)["C"] == "1"
214+
lid_is_open = utils.parse_key_values(value=limit_switch_status)["O"] == "1"
216215
match (lid_is_closed, lid_is_open):
217216
case (True, True):
218217
return ThermocyclerLidStatus.UNKNOWN

api/src/opentrons/drivers/thermocycler/simulator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ async def lift_plate(self) -> None:
5656
@ensure_yield
5757
async def get_lid_status(self) -> ThermocyclerLidStatus:
5858
return self._lid_status
59+
60+
@ensure_yield
61+
async def check_lid_status_for_real_this_time(self) -> ThermocyclerLidStatus:
62+
return self._lid_status
5963

6064
@ensure_yield
6165
async def get_lid_temperature(self) -> Temperature:

api/src/opentrons/hardware_control/modules/thermocycler.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import time
34
import asyncio
45
import logging
56
from typing import Callable, Optional, List, Dict, Mapping, Union, cast
@@ -241,24 +242,13 @@ async def _ensure_lid_closed(self, retry: bool = False) -> None:
241242
"""Ensure the lid is closed after close command"""
242243
switch_status = await self._driver.check_lid_status_for_real_this_time()
243244
if switch_status != ThermocyclerLidStatus.CLOSED:
244-
if retry:
245-
self._retry_close_lid()
245+
if not retry:
246+
await self.open()
247+
await self.close(retry = True)
246248
else:
247-
raise ThermocyclerError(
248-
f"Lid status is {switch_status} after close command, expected CLOSED."
249+
raise RuntimeError(
250+
f"Lid status is {switch_status} after close command, expected closed."
249251
)
250-
251-
async def _retry_close_lid(self) -> None:
252-
"""Retry closing the lid once if it is not closed after the first close command."""
253-
try:
254-
await self.open()
255-
await self.close(retry = True)
256-
except ThermocyclerError as e:
257-
log.warning(f"Retrying close lid due to error: {e}")
258-
await self._ensure_lid_closed()
259-
else:
260-
log.info("Lid closed successfully on retry.")
261-
262252

263253
async def lift_plate(self) -> str:
264254
"""If the lid is open, lift the plate.

0 commit comments

Comments
 (0)