Skip to content

Commit

Permalink
Write data and package versions to data/output
Browse files Browse the repository at this point in the history
  • Loading branch information
glass-ships committed Jan 23, 2024
1 parent 9fd9880 commit 4baae98
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/monarch_ingest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def callback(version: Optional[bool] = typer.Option(None, "--version", is_eager=
@typer_app.command()
def download(
ingests: Optional[List[str]] = typer.Option(None, help="Which ingests to download data for"),
all: bool = typer.Option(False, help="Download all ingest datasets")
all: bool = typer.Option(False, help="Download all ingest datasets"),
write_versions: bool = typer.Option(False, help="Write versions of ingests to versions.yaml")
):
"""Downloads data defined in download.yaml"""

Expand All @@ -47,6 +48,40 @@ def download(
output_dir='.'
)

if write_versions:
# TODO:
# - Find a way to get versions of other data sources
# - May need beautifulsoup to scrape some web pages
# - Split data and packages into separate sections
import requests as r
from importlib.metadata import version

packages = {}
data = {}

# get biolink model version
packages["biolink"] = version("biolink-model")
packages["monarch-ingest"] = version("monarch-ingest")

# github api query for mondo, phenio, hpo versions
data["phenio"] = r.get("https://api.github.com/repos/monarch-initiative/phenio/releases").json()[0]["tag_name"]
data["hpo"] = r.get("https://api.github.com/repos/obophenotype/human-phenotype-ontology/releases").json()[0]["tag_name"]
data["mondo"] = r.get("https://api.github.com/repos/monarch-initiative/mondo/releases").json()[0]["tag_name"]

# get alliance version from alliance api endpoint
data["alliance"] = r.get("https://fms.alliancegenome.org/api/releaseversion/current").json()["releaseVersion"]

# zfin -> daily build, no version (or use beautifulsoup)

# write to versions.yaml
with open("versions.yaml", "w") as f:
f.write("packages:\n")
for package, version in packages.items():
f.write(f" {package}: {version}\n")
f.write("data:\n")
for data_source, version in data.items():
f.write(f" {data_source}: {version}\n")


@typer_app.command()
def transform(
Expand Down

0 comments on commit 4baae98

Please sign in to comment.