Skip to content

Commit

Permalink
Merge pull request #210 from CogStack/vocab-upload-verification-fix
Browse files Browse the repository at this point in the history
CU-8695y7r4y: Fix vocab path check, also included edge case error Ind…
  • Loading branch information
tomolopolis authored Sep 25, 2024
2 parents a01e5bb + 52774b3 commit 55d159d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion webapp/api/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions webapp/api/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 55d159d

Please sign in to comment.