Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Sleeps do not happen in thermocycler and tempdeck when simulating. #7515

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/opentrons/hardware_control/modules/tempdeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ async def await_temperature(self, awaiting_temperature: float):
Polls temperature module's temperature until
the specified temperature is reached
"""
if self.is_simulated:
return

await self.wait_for_is_running()

async def _await_temperature(awaiting_temperature: float):
Expand Down
9 changes: 9 additions & 0 deletions api/src/opentrons/hardware_control/modules/thermocycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ async def wait_for_lid_temp(self):

Subject to change without a version bump.
"""
if self.is_simulated:
return

while self._driver.lid_temp_status != 'holding at target':
await asyncio.sleep(0.1)

Expand All @@ -206,13 +209,19 @@ async def wait_for_temp(self):

Subject to change without a version bump.
"""
if self.is_simulated:
return

while self.status != 'holding at target':
await asyncio.sleep(0.1)

async def wait_for_hold(self, hold_time=0):
"""
This method returns only when hold time has elapsed
"""
if self.is_simulated:
return

# If hold time is within the HOLD_TIME_FUZZY_SECONDS time gap, then,
# because of the driver's status poller delays, it is impossible to
# know for certain if self.hold_time holds the most recent value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import asyncio
from unittest import mock
import mock
from opentrons.hardware_control import modules, ExecutionManager

from opentrons.drivers.rpi_drivers.types import USBPort
Expand Down Expand Up @@ -161,13 +161,11 @@ def async_return(result):
set_temp_driver_mock.reset_mock()

# Test hold_time < HOLD_TIME_FUZZY_SECONDS. Here we know
# that asyncio.sleep will be called with the direct hold
# that wait_for_hold will be called with the direct hold
# time rather than increments of 0.1
sleep_mock = mock.Mock()
async_sleep_mock = mock.Mock(side_effect=asyncio.coroutine(sleep_mock))
monkeypatch.setattr(asyncio, 'sleep', async_sleep_mock)
hw_tc.wait_for_hold = mock.AsyncMock()
await hw_tc.set_temperature(40, hold_time_seconds=2)
async_sleep_mock.assert_called_once_with(2)
hw_tc.wait_for_hold.assert_called_once_with(2)
set_temp_driver_mock.assert_called_once_with(temp=40,
hold_time=2,
volume=None,
Expand Down