Skip to content

Commit f24806f

Browse files
fix: Accept numeric-only Machine ID in Mabtech APEX parser
Some APEX instruments export only a numeric serial number (e.g. "554") in the Machine ID field instead of the expected "Model Number" format (e.g. "IRIS 1234"). This caused parsing to fail with "Unable to interpret Machine ID". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0058b39 commit f24806f

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/allotropy/parsers/mabtech_apex/mabtech_apex_structure.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Metadata,
1414
ProcessedData,
1515
)
16-
from allotropy.exceptions import AllotropeParsingError
16+
from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
1717
from allotropy.parsers.constants import NOT_APPLICABLE
1818
from allotropy.parsers.mabtech_apex import constants
1919
from allotropy.parsers.utils.pandas import SeriesData
@@ -22,20 +22,25 @@
2222

2323

2424
def create_metadata(plate_info: SeriesData, file_path: str) -> Metadata:
25-
machine_id = assert_not_none(
26-
re.match(
27-
"([A-Z]+[a-z]*) ([0-9]+)",
28-
plate_info[str, "Machine ID"],
29-
),
30-
msg="Unable to interpret Machine ID",
31-
)
25+
raw_machine_id = plate_info[str, "Machine ID"]
26+
machine_id_match = re.match(r"([A-Z]+[a-z]*) ([0-9]+)", raw_machine_id)
27+
28+
if machine_id_match:
29+
model_number = machine_id_match.group(1)
30+
serial_number = machine_id_match.group(2)
31+
elif re.fullmatch(r"[0-9]+", raw_machine_id):
32+
model_number = NOT_APPLICABLE
33+
serial_number = raw_machine_id
34+
else:
35+
msg = f"Unable to interpret Machine ID: {raw_machine_id}"
36+
raise AllotropeConversionError(msg)
3237

3338
return Metadata(
3439
device_identifier=NOT_APPLICABLE,
3540
software_name=constants.SOFTWARE_NAME,
3641
software_version=plate_info.get(str, "Software Version"),
37-
model_number=machine_id.group(1),
38-
equipment_serial_number=machine_id.group(2),
42+
model_number=model_number,
43+
equipment_serial_number=serial_number,
3944
file_name=Path(file_path).name,
4045
unc_path=plate_info.get(str, "Path", file_path),
4146
custom_info=plate_info.get_unread(),

0 commit comments

Comments
 (0)