Skip to content

Commit

Permalink
fix: handle optional methods element gracefully
Browse files Browse the repository at this point in the history
Modify the `add_methods_annotations_to_workbook` function to gracefully
handle the optional methods element in EML files, preventing errors when
processing EML documents that lack this element.
  • Loading branch information
clnsmth authored Nov 8, 2024
1 parent d72647e commit 591ed67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/spinneret/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,12 @@ def add_methods_annotations_to_workbook(
},
)

# Get the methods annotations
# Get the methods annotations, if the methods element exists in the EML
dataset_element = eml.xpath("//dataset")[0]
element_description = get_description(eml.xpath("//dataset/methods")[0])
methods_element = eml.xpath("//dataset/methods")
if not methods_element:
return wb
element_description = get_description(methods_element[0])
annotations = get_ontogpt_annotation(
text=element_description,
template="uses_method",
Expand Down

0 comments on commit 591ed67

Please sign in to comment.