Skip to content

Commit

Permalink
Patch broken error handling in new quantit parser (#578)(patch)
Browse files Browse the repository at this point in the history
### Fixed
- The error messages sent out in the new Quant-iT parser
  • Loading branch information
Karl-Svard authored Jan 17, 2025
1 parent 214f724 commit 4a3df0a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cg_lims/EPPs/files/parsers/quantit_excel_to_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down

0 comments on commit 4a3df0a

Please sign in to comment.