Skip to content

Commit

Permalink
Merge pull request #109 from cancervariants/issue-103-staging
Browse files Browse the repository at this point in the history
fix: MONDO latest version retrieval (staging)
  • Loading branch information
korikuzma authored Jan 11, 2023
2 parents 21a9f3f + dfe5b60 commit f4966cf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion disease/etl/mondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Dict, List, Optional

import owlready2 as owl
import requests
from owlready2.rdflib_store import TripleLiteRDFlibGraph as RDFGraph

from disease import PREFIX_LOOKUP, logger
Expand Down Expand Up @@ -56,10 +57,25 @@
class Mondo(OWLBase):
"""Gather and load data from Mondo."""

def get_latest_version(self) -> str:
"""Get most recent version of MONDO from GitHub API.
:return: Most recent version, as a str
"""
response = requests.get(
"https://api.github.com/repos/monarch-initiative/mondo/releases/latest"
)
if response.status_code == 200:
return response.json()["name"].replace("v", "")
else:
raise requests.HTTPError(
f"Unable to retrieve MONDO version from GitHub "
f"API. Status code: {response.status_code}"
)

def _download_data(self):
"""Download Mondo thesaurus source file for loading into normalizer."""
logger.info("Downloading Mondo data...")
url = "http://purl.obolibrary.org/obo/mondo.owl"
url = f"http://purl.obolibrary.org/obo/mondo/releases/{self._version}/mondo.owl"
output_file = self._src_dir / f"mondo_{self._version}.owl"
self._http_download(url, output_file)
logger.info("Finished downloading Mondo Disease Ontology")
Expand Down

0 comments on commit f4966cf

Please sign in to comment.