Skip to content

Commit

Permalink
feat!: use mondo OBO release (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored Dec 4, 2023
1 parent d5f0480 commit fc013bb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "wags_tails"
version = "0.1.1"
version = "0.1.2"
authors = [
{name = "Kori Kuzma"},
{name = "James S Stevenson"},
Expand Down
18 changes: 9 additions & 9 deletions src/wags_tails/mondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MondoData(GitHubDataSource):
"""Provide access to Mondo disease ontology data."""

_src_name = "mondo"
_filetype = "owl"
_filetype = "obo"
_repo = "monarch-initiative/mondo"

@staticmethod
Expand All @@ -43,12 +43,12 @@ def _get_latest_version() -> Tuple[str, str]:
assets = data["assets"]
url = None
for asset in assets:
if asset["name"] == "mondo.owl":
if asset["name"] == "mondo.obo":
url = asset["browser_download_url"]
return (version, url)
else:
raise RemoteDataError(
f"Unable to retrieve mondo.owl under release {version}"
f"Unable to retrieve mondo.obo under release {version}"
)

def _download_data(self, version: str, outfile: Path) -> None:
Expand All @@ -61,7 +61,7 @@ def _download_data(self, version: str, outfile: Path) -> None:
"v%Y-%m-%d"
)
download_http(
f"https://github.com/monarch-initiative/mondo/releases/download/{formatted_version}/mondo.owl",
f"https://github.com/monarch-initiative/mondo/releases/download/{formatted_version}/mondo.obo",
outfile,
tqdm_params=self._tqdm_params,
)
Expand All @@ -82,11 +82,11 @@ def get_latest(
raise ValueError("Cannot set both `force_refresh` and `from_local`")

if from_local:
local_file = get_latest_local_file(self.data_dir, "mondo_*.owl")
return local_file, parse_file_version(local_file, r"mondo_(.*).owl")
local_file = get_latest_local_file(self.data_dir, "mondo_*.obo")
return local_file, parse_file_version(local_file, r"mondo_(.*).obo")

latest_version, data_url = self._get_latest_version()
latest_file = self.data_dir / f"mondo_{latest_version}.owl"
latest_file = self.data_dir / f"mondo_{latest_version}.obo"
if (not force_refresh) and latest_file.exists():
_logger.debug(
f"Found existing file, {latest_file.name}, matching latest version {latest_version}."
Expand All @@ -111,12 +111,12 @@ def get_specific(
if force_refresh and from_local:
raise ValueError("Cannot set both `force_refresh` and `from_local`")

local_file = self.data_dir / f"mondo_{version}.owl"
local_file = self.data_dir / f"mondo_{version}.obo"
if from_local:
if local_file.exists():
return local_file
else:
raise FileNotFoundError(f"No local file matching mondo_{version}.owl.")
raise FileNotFoundError(f"No local file matching mondo_{version}.obo.")

if (not force_refresh) and local_file.exists():
return local_file
Expand Down
30 changes: 15 additions & 15 deletions tests/test_mondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,36 @@ def test_get_latest(
json=latest_release_response,
)
m.get(
"https://github.com/monarch-initiative/mondo/releases/download/v2023-09-12/mondo.owl",
"https://github.com/monarch-initiative/mondo/releases/download/v2023-09-12/mondo.obo",
body="",
)
path, version = mondo.get_latest()
assert path == mondo_data_dir / "mondo_20230912.owl"
assert path == mondo_data_dir / "mondo_20230912.obo"
assert path.exists()
assert version == "20230912"
assert m.call_count == 2

path, version = mondo.get_latest()
assert path == mondo_data_dir / "mondo_20230912.owl"
assert path == mondo_data_dir / "mondo_20230912.obo"
assert path.exists()
assert version == "20230912"
assert m.call_count == 3

path, version = mondo.get_latest(from_local=True)
assert path == mondo_data_dir / "mondo_20230912.owl"
assert path == mondo_data_dir / "mondo_20230912.obo"
assert path.exists()
assert version == "20230912"
assert m.call_count == 3

(mondo_data_dir / "mondo_20230802.owl").touch()
(mondo_data_dir / "mondo_20230802.obo").touch()
path, version = mondo.get_latest(from_local=True)
assert path == mondo_data_dir / "mondo_20230912.owl"
assert path == mondo_data_dir / "mondo_20230912.obo"
assert path.exists()
assert version == "20230912"
assert m.call_count == 3

path, version = mondo.get_latest(force_refresh=True)
assert path == mondo_data_dir / "mondo_20230912.owl"
assert path == mondo_data_dir / "mondo_20230912.obo"
assert path.exists()
assert version == "20230912"
assert m.call_count == 5
Expand Down Expand Up @@ -126,42 +126,42 @@ def test_get_specific_version(

with requests_mock.Mocker() as m:
m.get(
"https://github.com/monarch-initiative/mondo/releases/download/v2023-08-02/mondo.owl",
"https://github.com/monarch-initiative/mondo/releases/download/v2023-08-02/mondo.obo",
body="",
)
response = mondo.get_specific("20230802")
assert response == mondo_data_dir / "mondo_20230802.owl"
assert response == mondo_data_dir / "mondo_20230802.obo"
assert response.exists()
assert m.call_count == 1

response = mondo.get_specific("20230802")
assert response == mondo_data_dir / "mondo_20230802.owl"
assert response == mondo_data_dir / "mondo_20230802.obo"
assert response.exists()
assert m.call_count == 1

response = mondo.get_specific("20230802", from_local=True)
assert response == mondo_data_dir / "mondo_20230802.owl"
assert response == mondo_data_dir / "mondo_20230802.obo"
assert response.exists()
assert m.call_count == 1

response = mondo.get_specific("20230802", force_refresh=True)
assert response == mondo_data_dir / "mondo_20230802.owl"
assert response == mondo_data_dir / "mondo_20230802.obo"
assert response.exists()
assert m.call_count == 2

with pytest.raises(FileNotFoundError):
response = mondo.get_specific("v2023-09-12", from_local=True)

m.get(
"https://github.com/monarch-initiative/mondo/releases/download/v2023-09-12/mondo.owl",
"https://github.com/monarch-initiative/mondo/releases/download/v2023-09-12/mondo.obo",
body="",
)
response = mondo.get_specific("20230912")
assert response == mondo_data_dir / "mondo_20230912.owl"
assert response == mondo_data_dir / "mondo_20230912.obo"
assert response.exists()
assert m.call_count == 3

response = mondo.get_specific("20230802")
assert response == mondo_data_dir / "mondo_20230802.owl"
assert response == mondo_data_dir / "mondo_20230802.obo"
assert response.exists()
assert m.call_count == 3

0 comments on commit fc013bb

Please sign in to comment.