From 2f43f8cb63cb17dd3192600a2c0dec10cf92d3b9 Mon Sep 17 00:00:00 2001 From: Rostyslav Stekh Date: Tue, 25 Feb 2025 11:52:28 +0200 Subject: [PATCH] FIND-743 Fix pdf validation error --- submission/services/file_import/base.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/submission/services/file_import/base.py b/submission/services/file_import/base.py index 74fa898..1b68494 100644 --- a/submission/services/file_import/base.py +++ b/submission/services/file_import/base.py @@ -180,7 +180,11 @@ def validate_dataframe(self, dataframe: pd.DataFrame): dataframe.columns = dataframe.columns.str.strip() - dupe_cols = [col for col in dataframe.columns if col.endswith(".1")] + try: + dupe_cols = [col for col in dataframe.columns if col.endswith(".1")] + except AttributeError as exc: + raise ValidationError("Not all columns names are sting.") from exc + if dupe_cols: # Column names should be unique # This check relies on mangle_dupe_cols=True when reading table @@ -199,10 +203,7 @@ def validate_dataframe(self, dataframe: pd.DataFrame): # since we have all types as strings here, # we can check empty and whitespace values like that empty_values = ~dataframe[mandatory_col].str.strip().astype(bool) - if ( - mandatory_col in self.NON_NULL_COLUMNS - and not dataframe[empty_values].empty - ): + if mandatory_col in self.NON_NULL_COLUMNS and not dataframe[empty_values].empty: raise ValidationError( f"{mandatory_col}: Empty values in mandatory column.", ) @@ -229,9 +230,7 @@ def parse_row_named_columns(self, row): "sample_id": row["Sample Id"], "medium": row["DST Method"], "fastq_prefix": ( - row["FASTQ prefix"].strip().rstrip("_") - if row.get("FASTQ prefix") - else None + row["FASTQ prefix"].strip().rstrip("_") if row.get("FASTQ prefix") else None ), "tests": [], "metadata": {},