From 9415984cab09ef73f645cee1eaa7e144825f02d4 Mon Sep 17 00:00:00 2001 From: Vincent Emonet Date: Wed, 23 Oct 2024 13:56:54 +0200 Subject: [PATCH] ignore errors with missmatching categories code --- backend/src/upload.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/upload.py b/backend/src/upload.py index 633ec47..486afc1 100644 --- a/backend/src/upload.py +++ b/backend/src/upload.py @@ -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) @@ -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")) @@ -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