Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-8695y7r4y: Fix vocab path check, also included edge case error Ind… #210

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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