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

FIND-743 Fix pdf validation error #35

Merged
merged 1 commit into from
Feb 25, 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: 7 additions & 8 deletions submission/services/file_import/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.",
)
Expand All @@ -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": {},
Expand Down