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

chore(refactor): Refactor and cleanup volumetric scripts #13071

Merged
merged 53 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1775461
Revert "Merge latest volumetric changes (#13100)"
ryanthecoder Jul 18, 2023
6f174c2
Revert "fix(hardware-testing): Remove tips using them for finding liq…
ryanthecoder Jul 10, 2023
4c284c3
Revert "support resupplying tipracks during a 96ch increment test run…
ryanthecoder Jul 10, 2023
dad71d9
Pull out all of the common functions between gravimetric and photometric
ryanthecoder Jun 28, 2023
99dd0b4
move trial generation out of excecute
ryanthecoder Jun 30, 2023
e696fb5
combine the load pipette logic
ryanthecoder Jul 5, 2023
6c80ff9
pull gantry speed out of the photometric config
ryanthecoder Jul 5, 2023
0c805ed
refactor out load tipracks
ryanthecoder Jul 6, 2023
feffd7c
remove unused method
ryanthecoder Jul 6, 2023
7659f5d
fix issues from rebasing
ryanthecoder Jul 6, 2023
4f36525
fixups from rebase and formating
ryanthecoder Jul 6, 2023
53c9e22
refactor out trial building from the photometric script
ryanthecoder Jul 6, 2023
00fd080
add additional test targets
ryanthecoder Jul 6, 2023
c8cae41
pull out the common elements of trials into a seperate dataclass
ryanthecoder Jul 6, 2023
138d439
break out even more common code
ryanthecoder Jul 6, 2023
d79bd0b
break building pm report out of the run method
ryanthecoder Jul 7, 2023
56f05e4
break the run trials loop out of the run method
ryanthecoder Jul 7, 2023
784555a
format/lint
ryanthecoder Jul 7, 2023
3f95dcc
break building test report out of the run method in gravimetric run m…
ryanthecoder Jul 7, 2023
b7b1dfa
add the ui header to the build_report methods
ryanthecoder Jul 7, 2023
8f6fbb5
move all of the dye prep into the dye prep method
ryanthecoder Jul 7, 2023
407c5e1
improve LiquidTracker initialization
ryanthecoder Jul 7, 2023
29f4d86
move the homing to execute_trials
ryanthecoder Jul 7, 2023
0e8cd1e
refactor out common end script code
ryanthecoder Jul 7, 2023
ac36081
refactor out common get_tips
ryanthecoder Jul 7, 2023
46152f0
fixup things that broke during rebase
ryanthecoder Jul 10, 2023
07f0b95
fix the photometric test target
ryanthecoder Jul 10, 2023
bcce969
remove evaporation measurement out of run for readablity
ryanthecoder Jul 10, 2023
4779eb3
break out load scale for readablity
ryanthecoder Jul 10, 2023
2360c8a
redo: Support resupplying tipracks during a 96ch increment tests
ryanthecoder Jul 10, 2023
f30597b
redo: Remove tips using them for finding liquid height
ryanthecoder Jul 10, 2023
42f1b10
fix the tests
ryanthecoder Jul 10, 2023
f0f8af9
replace all print statements with ui
ryanthecoder Jul 11, 2023
60fc05f
move the if-else out of the function to decrease the indent
ryanthecoder Jul 11, 2023
2d78eba
make a base class config
ryanthecoder Jul 11, 2023
d9c8e24
fixup things that were lost in the rebase
ryanthecoder Jul 11, 2023
6b8ce30
construct the trial directory correctly
ryanthecoder Jul 14, 2023
2bcc4e9
make sure 96 pipette doesn't collide during gravimetric tests
ryanthecoder Jul 18, 2023
a7e7a92
gracefully handle when the scale is beyond max
ryanthecoder Jul 18, 2023
9cd5abe
reimplement: Merge latest volumetric changes (#13100)
ryanthecoder Jul 18, 2023
44c37c3
add stable flag to the blank gravimetric trials
ryanthecoder Jul 19, 2023
56e2bf4
Convert the default test volumes to the QC volumes
ryanthecoder Jul 12, 2023
9851c2b
add default number of trials and correct volumes to match calculator …
ryanthecoder Jul 19, 2023
dbbc810
make blank the default
ryanthecoder Jul 19, 2023
97b11d3
update makefile to test the correct args for each tip
ryanthecoder Jul 20, 2023
d17b9dc
update increment test values
ryanthecoder Jul 21, 2023
e708dbe
make single channle QC test work with all tips in one run
ryanthecoder Jul 21, 2023
e96909a
last few changes
ryanthecoder Jul 21, 2023
e05a70b
fixup typing error
ryanthecoder Jul 24, 2023
200bb23
forgot a docstring for the linter
ryanthecoder Jul 24, 2023
21915e9
support the enviornmental sensor in the volumetric tests
ryanthecoder Jul 24, 2023
8092346
make the asair prompt for port instead of auto finding
ryanthecoder Jul 24, 2023
da2b26d
fix the tests
ryanthecoder Jul 25, 2023
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
4 changes: 2 additions & 2 deletions hardware-testing/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
max-line-length = 100

# max cyclomatic complexity
# NOTE: (andy s) increasing this from 9 to 20 b/c test scripts often handle all logic in main
max-complexity = 20
# NOTE: (andy s) increasing this from 9 to 15 b/c test scripts often handle all logic in main
max-complexity = 15

extend-ignore =
# ignore E203 because black might reformat it
Expand Down
29 changes: 17 additions & 12 deletions hardware-testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,29 @@ test-cov:

.PHONY: test-photometric
test-photometric:
$(python) -m hardware_testing.gravimetric --photometric --simulate --pipette 1000 --channels 96 --tip 50 --trials 5
$(python) -m hardware_testing.gravimetric --photometric --simulate --pipette 1000 --channels 96 --tip 200 --trials 5
-$(MAKE) apply-patches-gravimetric
$(python) -m hardware_testing.gravimetric --photometric --simulate --pipette 1000 --channels 96 --tip 50 --trials 1
$(python) -m hardware_testing.gravimetric --photometric --simulate --pipette 1000 --channels 96 --tip 200 --trials 1
-$(MAKE) remove-patches-gravimetric

.PHONY: test-gravimetric-single
test-gravimetric-single:
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --tip 1000 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --tip 200 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --tip 50 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 1 --tip 50 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --tip 1000 --trials 1 --increment
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --extra --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 1 --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 1 --trials 1 --increment --no-blank

.PHONY: test-gravimetric-multi
test-gravimetric-multi:
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 8 --tip 50 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 8 --tip 50 --trials 1 --increment
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 1000 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 200 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 50 --trials 1
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 8 --tip 50 --trials 1 --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 50 --channels 8 --tip 50 --trials 1 --increment --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 1000 --trials 1 --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 200 --trials 1 --extra --no-blank
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 8 --tip 50 --trials 1 --no-blank

.PHONY: test-gravimetric-96
test-gravimetric-96:
$(python) -m hardware_testing.gravimetric --simulate --pipette 1000 --channels 96 --tip 1000 --trials 1 --no-blank

.PHONY: test-gravimetric
test-gravimetric:
Expand Down
15 changes: 14 additions & 1 deletion hardware-testing/hardware_testing/data/ui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Production QC User Interface."""

from opentrons.hardware_control import SyncHardwareAPI
from opentrons.hardware_control.types import StatusBarState

PRINT_HEADER_NUM_SPACES = 4
PRINT_HEADER_DASHES = "-" * PRINT_HEADER_NUM_SPACES
Expand All @@ -25,6 +26,13 @@ def get_user_ready(message: str) -> None:
input(f"WAIT: {message}, press ENTER when ready: ")


def alert_user_ready(message: str, hw: SyncHardwareAPI) -> None:
"""Flash the ui lights on the ot3 and then use the get_user_ready."""
hw.set_status_bar_state(StatusBarState.PAUSED)
get_user_ready(message)
hw.set_status_bar_state(StatusBarState.CONFIRMATION)


def print_title(title: str) -> None:
"""Print title."""
"""
Expand Down Expand Up @@ -54,3 +62,8 @@ def print_header(header: str) -> None:
def print_error(message: str) -> None:
"""Print error."""
print(f"ERROR: {message}")


def print_info(message: str) -> None:
"""Print information."""
print(message)
1 change: 0 additions & 1 deletion hardware-testing/hardware_testing/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from serial.tools.list_ports import comports # type: ignore[import]

from .radwag import RadwagScaleBase, RadwagScale, SimRadwagScale
from .asair_sensor import AsairSensor, AsairSensorError


def list_ports_and_select(device_name: str = "") -> str:
Expand Down
22 changes: 18 additions & 4 deletions hardware-testing/hardware_testing/drivers/asair_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import abc
import codecs
import logging
import random
import time
from typing import Tuple
from abc import ABC
from dataclasses import dataclass

from . import list_ports_and_select
import serial # type: ignore[import]
from serial.serialutil import SerialException # type: ignore[import]
from hardware_testing.data import ui

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -66,6 +66,20 @@ def get_reading(self) -> Reading:
...


def BuildAsairSensor(simulate: bool) -> AsairSensorBase:
"""Try to find and return an Asair sensor, if not found return a simulator."""
ui.print_title("Connecting to Environmental sensor")
if not simulate:
port = list_ports_and_select(device_name="Asair environmental sensor")
try:
sensor = AsairSensor.connect(port)
ui.print_info(f"Found sensor on port {port}")
return sensor
except SerialException:
pass
return SimAsairSensor()


class AsairSensor(AsairSensorBase):
"""Asair sensor driver."""

Expand Down Expand Up @@ -152,6 +166,6 @@ class SimAsairSensor(AsairSensorBase):

def get_reading(self) -> Reading:
"""Get a reading."""
temp = random.uniform(24.5, 25)
relative_hum = random.uniform(45, 40)
temp = 25.0
relative_hum = 50.0
return Reading(temperature=temp, relative_humidity=relative_hum)
19 changes: 12 additions & 7 deletions hardware-testing/hardware_testing/drivers/radwag/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@ def _on_unstable_measurement(
data = RadwagResponse.build(command, response_list)
# SI ? - 0.00020 g
# TODO: we could accept more unit types if we wanted...
assert response_list[-1] == "g", (
f'Expected units to be grams ("g"), ' f'instead got "{response_list[-1]}"'
)
data.stable = "?" not in response_list
data.measurement = float(response_list[-2])
if "-" in response_list:
data.measurement *= -1
if RadwagResponseCodes.MAX_THRESHOLD_EXCEEDED in response_list:
print("Warning: Scale maximum exceeded returning infinity")
data.stable = False
data.measurement = float("inf")
else:
assert response_list[-1] == "g", (
f'Expected units to be grams ("g"), ' f'instead got "{response_list[-1]}"'
)
data.stable = "?" not in response_list
data.measurement = float(response_list[-2])
if "-" in response_list:
data.measurement *= -1
return data


Expand Down
Loading