From 171294fb44ecbec34094f669278deb977916e836 Mon Sep 17 00:00:00 2001 From: janekg89 Date: Tue, 21 Jun 2022 10:33:47 +0200 Subject: [PATCH] better validation error reporting --- backend/pkdb_app/data/models.py | 3 ++- backend/pkdb_app/outputs/pk_calculation.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/pkdb_app/data/models.py b/backend/pkdb_app/data/models.py index 2845bda6..45549e25 100644 --- a/backend/pkdb_app/data/models.py +++ b/backend/pkdb_app/data/models.py @@ -214,7 +214,8 @@ def validate_timecourse(self, timecourse): name = self.get_name(timecourse[key], value) else: name = list(timecourse[key]) - raise ValueError(f"Subset used for timecourse is not unique on '{key}'. Values are '{name}'. " + label = timecourse['label'] + raise ValueError(f"Subset with label '{label}' used for timecourse is not unique on '{key}'. Values are '{name}'. " f"Check uniqueness of labels for timecourses.") diff --git a/backend/pkdb_app/outputs/pk_calculation.py b/backend/pkdb_app/outputs/pk_calculation.py index 73fb5652..5e563bb1 100644 --- a/backend/pkdb_app/outputs/pk_calculation.py +++ b/backend/pkdb_app/outputs/pk_calculation.py @@ -43,9 +43,11 @@ def pkoutputs_from_timecourse(subset: Subset) -> List[Dict]: if dosing: if dosing.application.info_node.name == "single dose" and timecourse["substance"] == dosing.substance.pk: pkinf = pharmacokinetics.TimecoursePK(**variables) + if not pkinf: _ = variables.pop("dosing", None) _ = variables.pop("intervention_time", None) + print(variables) pkinf = pharmacokinetics.TimecoursePKNoDosing(**variables) pk = pkinf.pk