From dfe5b607c3031f26956d84b8122ae4bde0c893e2 Mon Sep 17 00:00:00 2001 From: korikuzma Date: Wed, 11 Jan 2023 10:02:42 -0500 Subject: [PATCH] fix: MONDO latest veresion retrieval --- disease/etl/mondo.py | 18 +++++++++++++++++- disease/version.py | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/disease/etl/mondo.py b/disease/etl/mondo.py index 2737e55e..cadc7f54 100644 --- a/disease/etl/mondo.py +++ b/disease/etl/mondo.py @@ -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 @@ -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") diff --git a/disease/version.py b/disease/version.py index d49b9ad8..a55473f9 100644 --- a/disease/version.py +++ b/disease/version.py @@ -1,2 +1,2 @@ """Disease normalizer version""" -__version__ = "0.3.0" +__version__ = "0.3.1"