diff --git a/webapp/api/api/models.py b/webapp/api/api/models.py index a10ce479..f69385c5 100644 --- a/webapp/api/api/models.py +++ b/webapp/api/api/models.py @@ -137,7 +137,7 @@ def save(self, *args, skip_load=False, **kwargs): # load the Vocab, and raise if this fails if not skip_load: try: - Vocab.load(self.vocab_file) + Vocab.load(self.vocab_file.path) 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 diff --git a/webapp/api/api/utils.py b/webapp/api/api/utils.py index 41039dfe..03354f26 100644 --- a/webapp/api/api/utils.py +++ b/webapp/api/api/utils.py @@ -47,8 +47,9 @@ def add_annotations(spacy_doc, user, project, document, existing_annotations, ca for task_name in spacy_doc._.ents[0]._.meta_anns.keys()} metataskvals2obj = {task_name: {v.name: v for v in MetaTask.objects.get(name=task_name).values.all()} for task_name in spacy_doc._.ents[0]._.meta_anns.keys()} - except AttributeError: - # ignore meta_anns that are not present - i.e. non model pack preds, + except (AttributeError, IndexError): + # IndexError: ignore if there are no annotations in this doc + # AttributeError: ignore meta_anns that are not present - i.e. non model pack preds # or model pack preds with no meta_anns metatask2obj = {} metataskvals2obj = {}