From 461af169a089a7bd9bb0fa15438db19fbbcd33cb Mon Sep 17 00:00:00 2001 From: "Yang.Noah.Lin" Date: Tue, 22 Oct 2024 11:33:24 +0800 Subject: [PATCH] fix: vocab_file should be saved before loading --- webapp/api/api/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/api/api/models.py b/webapp/api/api/models.py index dd8b021..b1905e2 100644 --- a/webapp/api/api/models.py +++ b/webapp/api/api/models.py @@ -135,6 +135,8 @@ class Vocabulary(models.Model): vocab_file = models.FileField() def save(self, *args, skip_load=False, **kwargs): + super().save(*args, **kwargs) + # load the Vocab, and raise if this fails if not skip_load: try: @@ -142,7 +144,6 @@ def save(self, *args, skip_load=False, **kwargs): except Exception as exc: raise MedCATLoadException(f'Failed to load Vocab from {self.vocab_file}, ' f'check if this Vocab file successfully loads elsewhere') from exc - super().save(*args, **kwargs) def __str__(self): return str(self.vocab_file.name)