From b6b18f732d94420631bbd74920af459d8c713145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Sv=C3=A4rd?= Date: Fri, 17 Jan 2025 13:39:29 +0100 Subject: [PATCH] fix error msgs --- .../EPPs/files/parsers/quantit_excel_to_udf.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cg_lims/EPPs/files/parsers/quantit_excel_to_udf.py b/cg_lims/EPPs/files/parsers/quantit_excel_to_udf.py index ee4c1a71..477eb085 100644 --- a/cg_lims/EPPs/files/parsers/quantit_excel_to_udf.py +++ b/cg_lims/EPPs/files/parsers/quantit_excel_to_udf.py @@ -14,16 +14,14 @@ LOG = logging.getLogger(__name__) -def set_udfs(udf: str, well_dict: dict, result_file: Path): +def set_udfs(udf: str, well_dict: Dict[str, Artifact], result_file: Path): """Reads the Quant-iT Excel file and sets the value for each sample""" failed_artifacts: int = 0 - skipped_artifacts: int = 0 df: pd.DataFrame = pd.read_excel(result_file, skiprows=11, header=None) for index, row in df.iterrows(): if row[0] not in well_dict.keys(): LOG.info(f"Well {row[0]} is not used by a sample in the step, skipping.") - skipped_artifacts += 1 continue elif pd.isna(row[2]): LOG.info( @@ -35,13 +33,10 @@ def set_udfs(udf: str, well_dict: dict, result_file: Path): artifact.udf[udf] = row[2] artifact.put() - if failed_artifacts or skipped_artifacts: - error_message: str = "Warning:" - if failed_artifacts: - error_message += f" Skipped {failed_artifacts} artifact(s) with wrong and/or blank values for some UDFs." - if skipped_artifacts: - error_message += f" Skipped {failed_artifacts} artifact(s) as they weren't represented in the result file." - raise MissingArtifactError(error_message) + if failed_artifacts: + raise MissingArtifactError( + f"Warning: Skipped {failed_artifacts} artifact(s) with wrong and/or blank values for some UDFs." + ) @click.command()