Skip to content

Commit

Permalink
Merge pull request #34 from ccb-hms/development
Browse files Browse the repository at this point in the history
Fix Cache Ontology Set Bug
  • Loading branch information
paynejason authored May 10, 2023
2 parents 3e1816b + 70d95c2 commit fa91e27
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions test/simple-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def main():
# cached_onto = text2term.cache_ontology("EFO")
# # df = cached_onto.map_terms(["asthma", "disease location", "obsolete food allergy"], excl_deprecated=True, term_type="classes")
# print("Cache exists:", cached_onto.cache_exists())
# df = text2term.map_terms(["asthma", "disease location", "obsolete food allergy"], "EFO", excl_deprecated=True, use_cache=True, term_type="classes")
df = text2term.map_terms(["contains", "asthma"], "EFO", term_type="classes")
caches = text2term.cache_ontology_set("text2term/resources/ontologies.csv")
df = text2term.map_terms(["asthma", "disease location", "obsolete food allergy"], "EFO", excl_deprecated=True, use_cache=True, term_type="classes")
# df = text2term.map_terms(["contains", "asthma"], "EFO", term_type="classes")
print(df.to_string())

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion text2term/config.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.3.0"
VERSION = "2.3.1"
5 changes: 4 additions & 1 deletion text2term/onto_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
from shutil import rmtree
import sys
import pandas as pd
import owlready2

"""
CACHING FUNCTIONS -- Public
Expand All @@ -16,7 +18,8 @@ def cache_ontology_set(ontology_registry_path):
cache = text2term.cache_ontology(row.url, row.acronym)
cache_set.update({row.acronym : cache})
except Exception as err:
sys.stderr.write("Could not cache ontology", row.acronym, "due to error:", err)
err_message = "Could not cache ontology " + row.acronym + " due to error: " + str(err)
sys.stderr.write(err_message)
owlready2.default_world.ontologies.clear()
return cache_set

Expand Down

0 comments on commit fa91e27

Please sign in to comment.