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 serial number parser to include BYO and OPT delims. #16650

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions api/src/opentrons/drivers/absorbance_reader/async_byonoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

SN_PARSER = re.compile(r'ATTRS{serial}=="(?P<serial>.+?)"')
VERSION_PARSER = re.compile(r"Absorbance (?P<version>V\d+\.\d+\.\d+)")
SERIAL_PARSER = re.compile(r"(?P<serial>BYO[A-Z]{3}[0-9]{5})")
SERIAL_PARSER = re.compile(r"(?P<serial>(OPT|BYO)[A-Z]{3}[0-9]{5})")


class AsyncByonoy:
Expand Down Expand Up @@ -158,7 +158,7 @@ async def get_device_information(self) -> Dict[str, str]:
self._raise_if_error(err.name, f"Error getting device information: {err}")
serial_match = SERIAL_PARSER.match(device_info.sn)
version_match = VERSION_PARSER.match(device_info.version)
serial = serial_match["serial"] if serial_match else "BYOMAA00000"
serial = serial_match["serial"] if serial_match else "OPTMAA00000"
version = version_match["version"].lower() if version_match else "v0.0.0"
info = {
"serial": serial,
Expand Down
33 changes: 32 additions & 1 deletion api/tests/opentrons/drivers/absorbance_reader/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,39 @@ async def test_driver_get_device_info(

info = await connected_driver.get_device_info()

mock_interface.get_device_information.assert_called_once()
assert info == {"serial": "BYOMAA00013", "model": "ABS96", "version": "v1.0.2"}
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()

# Test Device info with updated serial format
DEVICE_INFO.sn = "OPTMAA00034"
DEVICE_INFO.version = "Absorbance V1.0.2 2024-04-18"

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": "v1.0.2"}
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()

# Test Device info with invalid serial format
DEVICE_INFO.sn = "YRFGHVMAA00034"
DEVICE_INFO.version = "Absorbance V1.0.2 2024-04-18"

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

info = await connected_driver.get_device_info()

assert info == {"serial": "OPTMAA00000", "model": "ABS96", "version": "v1.0.2"}
mock_interface.get_device_information.assert_called_once()
mock_interface.reset_mock()


@pytest.mark.parametrize(
Expand Down
Loading