Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch broken error handling in new quantit parser #578

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading