From ed13ebad3ecfb3e998aa6039338c8ae53cdbfacb Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Mon, 23 Jun 2025 19:51:31 -0400 Subject: [PATCH 1/3] Use bytes for cds --- .../agilent_openlab_cds/agilent_openlab_cds_decoder.py | 4 ++-- .../parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py index 5246325c0..b1511a046 100644 --- a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py +++ b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py @@ -273,7 +273,7 @@ def _get_matching_filenames(zip_ref: zipfile.ZipFile, pattern: str) -> list[str] ] -def decode_data(input_path: str) -> dict[str, Any]: +def decode_data(input_bytes: IO[bytes]) -> dict[str, Any]: """ decoded the files in input folder path and returns a structured data :param input_path: input folder path @@ -284,7 +284,7 @@ def decode_data(input_path: str) -> dict[str, Any]: total_injection_chromatogram_details: list[dict[str, Any]] = [] total_peak_details: list[dict[str, Any]] = [] - with zipfile.ZipFile(input_path, "r") as zip_ref: + with zipfile.ZipFile(input_bytes) as zip_ref: acaml_path = next(iter(_get_matching_filenames(zip_ref, ".*acaml"))) with zip_ref.open(acaml_path) as acaml_file_data: acaml_file_content = acaml_file_data.read().decode("utf-8-sig") diff --git a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py index f4e7bdb46..6dafb018a 100644 --- a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py +++ b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py @@ -26,7 +26,7 @@ class AgilentOpenLabCDSParser(VendorParser[Data, Model]): SCHEMA_MAPPER = Mapper def create_data(self, named_file_contents: NamedFileContents) -> Data: - structured_data = decode_data(named_file_contents.original_file_path) + structured_data = decode_data(named_file_contents.contents) return Data( metadata=create_metadata(structured_data, named_file_contents), measurement_groups=[create_measurement_groups(structured_data)], From 3e32d8c41176748bf9fa30e44ba1ffce41be824e Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Mon, 23 Jun 2025 19:54:26 -0400 Subject: [PATCH 2/3] Use bytes for cds --- .../agilent_openlab_cds/agilent_openlab_cds_decoder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py index b1511a046..44d23972f 100644 --- a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py +++ b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py @@ -9,6 +9,8 @@ import rainbow.agilent.chemstation as rb # type: ignore import xmltodict +from allotropy.types import IOType + def merge_peak_with_signal_name( peak_data: list[dict[str, Any]], @@ -273,7 +275,7 @@ def _get_matching_filenames(zip_ref: zipfile.ZipFile, pattern: str) -> list[str] ] -def decode_data(input_bytes: IO[bytes]) -> dict[str, Any]: +def decode_data(input_bytes: IOType) -> dict[str, Any]: """ decoded the files in input folder path and returns a structured data :param input_path: input folder path From 50f69b9933ded0bb5b97d008400c291e6eee9105 Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Mon, 23 Jun 2025 20:05:10 -0400 Subject: [PATCH 3/3] Use bytes stream --- .../agilent_openlab_cds/agilent_openlab_cds_decoder.py | 4 +--- .../parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py index 44d23972f..b1511a046 100644 --- a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py +++ b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_decoder.py @@ -9,8 +9,6 @@ import rainbow.agilent.chemstation as rb # type: ignore import xmltodict -from allotropy.types import IOType - def merge_peak_with_signal_name( peak_data: list[dict[str, Any]], @@ -275,7 +273,7 @@ def _get_matching_filenames(zip_ref: zipfile.ZipFile, pattern: str) -> list[str] ] -def decode_data(input_bytes: IOType) -> dict[str, Any]: +def decode_data(input_bytes: IO[bytes]) -> dict[str, Any]: """ decoded the files in input folder path and returns a structured data :param input_path: input folder path diff --git a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py index 6dafb018a..fbc64a6d7 100644 --- a/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py +++ b/src/allotropy/parsers/agilent_openlab_cds/agilent_openlab_cds_parser.py @@ -26,7 +26,7 @@ class AgilentOpenLabCDSParser(VendorParser[Data, Model]): SCHEMA_MAPPER = Mapper def create_data(self, named_file_contents: NamedFileContents) -> Data: - structured_data = decode_data(named_file_contents.contents) + structured_data = decode_data(named_file_contents.get_bytes_stream()) return Data( metadata=create_metadata(structured_data, named_file_contents), measurement_groups=[create_measurement_groups(structured_data)],