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): update the plate reader parsing of the serial + version to account for the new format. #16824

Merged
merged 2 commits into from
Nov 15, 2024
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
9 changes: 5 additions & 4 deletions api/src/opentrons/drivers/absorbance_reader/async_byonoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@


SN_PARSER = re.compile(r'ATTRS{serial}=="(?P<serial>.+?)"')
VERSION_PARSER = re.compile(r"Absorbance (?P<version>V\d+\.\d+\.\d+)")
# match semver V0.0.0 (old format) or one integer (latest format)
VERSION_PARSER = re.compile(r"(?P<version>(V\d+\.\d+\.\d+|^\d+$))")
SERIAL_PARSER = re.compile(r"(?P<serial>(OPT|BYO)[A-Z]{3}[0-9]+)")


Expand Down Expand Up @@ -156,10 +157,10 @@ async def get_device_information(self) -> Dict[str, str]:
func=partial(self._interface.get_device_information, handle),
)
self._raise_if_error(err.name, f"Error getting device information: {err}")
serial_match = SERIAL_PARSER.fullmatch(device_info.sn)
version_match = VERSION_PARSER.match(device_info.version)
serial_match = SERIAL_PARSER.match(device_info.sn)
version_match = VERSION_PARSER.search(device_info.version)
serial = serial_match["serial"].strip() if serial_match else "OPTMAA00000"
version = version_match["version"].lower() if version_match else "v0.0.0"
version = version_match["version"].lower() if version_match else "v0"
info = {
"serial": serial,
"version": version,
Expand Down
30 changes: 30 additions & 0 deletions api/tests/opentrons/drivers/absorbance_reader/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,36 @@ async def test_driver_get_device_info(
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()

# Test Device info with updated version format
DEVICE_INFO.sn = "OPTMAA00034"
DEVICE_INFO.version = "8"

mock_interface.get_device_information.return_value = (
MockErrorCode.NO_ERROR,
DEVICE_INFO,
)

info = await connected_driver.get_device_info()

assert info == {"serial": "OPTMAA00034", "model": "ABS96", "version": "8"}
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()

# Test Device info with invalid version format
DEVICE_INFO.sn = "OPTMAA00034"
DEVICE_INFO.version = "asd"

mock_interface.get_device_information.return_value = (
MockErrorCode.NO_ERROR,
DEVICE_INFO,
)

info = await connected_driver.get_device_info()

assert info == {"serial": "OPTMAA00034", "model": "ABS96", "version": "v0"}
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()


@pytest.mark.parametrize(
"parts_aligned, module_status",
Expand Down
Loading