Skip to content

Commit

Permalink
ignore errors with missmatching categories code
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Oct 23, 2024
1 parent 0307e5f commit 9415984
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/src/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def load_cohort_dict_file(dict_path: str, cohort_id: str) -> Dataset:
detail="Only CSV files are supported. Please convert your file to CSV and try again.",
)
errors: list[str] = []
warnings: list[str] = []
try:
# Record all errors and raise them at the end
df = pd.read_csv(dict_path)
Expand Down Expand Up @@ -270,7 +271,8 @@ def load_cohort_dict_file(dict_path: str, cohort_id: str) -> Dataset:
else:
g.add((cat_uri, ICARE.conceptId, URIRef(cat_code_uri), cohort_uri))
except Exception:
errors.append(
# TODO: improve handling of categories
warnings.append(
f"Row {i+2} for variable `{row['VARIABLE NAME']}` the {len(categories_codes)} category concept codes are not matching with {len(row['categories'])} categories provided."
)
# print(g.serialize(format="turtle"))
Expand All @@ -288,6 +290,8 @@ def load_cohort_dict_file(dict_path: str, cohort_id: str) -> Dataset:
detail=str(e)[5:],
# detail=str(e),
)
if len(warnings) > 0:
logging.warning(f"Warnings uploading {cohort_id}: {"\n\n".join(warnings)}")
return g


Expand Down

0 comments on commit 9415984

Please sign in to comment.