Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes for Jenkins #74

Merged
merged 7 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,13 @@ pipeline {
script {
// Get the names of all BioPortal ontologies
// This saves the list to data/raw/ontologylist.tsv
sh ". venv/bin/activate && kgbioportal get-ontology-list --api_key ${NCBO_API_KEY}"
//sh ". venv/bin/activate && kgbioportal -vvv get-ontology-list --api_key ${NCBO_API_KEY}"

// For now, we use the pre-built list included with the repo.

// Now download all
// or at least in the future, do them all.
// For now just do a few
sh "printf 'ENVO\nPO\nSEPIO\n' > data/raw/ontologylist.tsv"

// Download the ontologies
// This saves them to data/raw/
sh ". venv/bin/activate && kgbioportal download --api_key ${NCBO_API_KEY} --ontology_file data/raw/ontologylist.tsv"
sh ". venv/bin/activate && kgbioportal download --api_key ${NCBO_API_KEY}"

}
}
Expand All @@ -105,8 +102,10 @@ pipeline {
dir('./gitrepo') {
script {

if (env.GIT_BRANCH != 'origin/main') {
echo "Will not push if not on main branch."
//if (env.GIT_BRANCH != 'origin/main') {
// echo "Will not push if not on main branch."
if (1 == 1) {
echo "TESTING."
} else {
withCredentials([
file(credentialsId: 's3cmd_kg_hub_push_configuration', variable: 'S3CMD_CFG'),
Expand Down
4 changes: 4 additions & 0 deletions data/raw/ontologylist.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id name current_version submission_id
ABA-AMB Allen Brain Atlas (ABA) Adult Mouse Brain Ontology 1 1
ABD Anthology of Biosurveillance Diseases NA 4
ACESO Adverse Childhood Experiences Ontology Light 2
8 changes: 5 additions & 3 deletions src/kg_bioportal/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import logging
import os
import time

import requests

ONTOLOGY_LIST_NAME = "ontologylist.tsv"
Expand Down Expand Up @@ -134,14 +136,12 @@ def get_ontology_list(self) -> None:
with open(f"{self.output_dir}/{ONTOLOGY_LIST_NAME}", "w") as outfile:
outfile.write(f"id\tname\tcurrent_version\tsubmission_id\n")
for acronym in ontologies:
metadata_url = f"https://data.bioontology.org/ontologies/{acronym}"
metadata = requests.get(metadata_url, headers=headers).json()
latest_submission_url = f"https://data.bioontology.org/ontologies/{acronym}/latest_submission"
latest_submission = requests.get(
latest_submission_url, headers=headers
).json()

name = metadata["name"].replace("\n", " ").replace("\t", " ")
name = latest_submission["ontology"]["name"].replace("\n", " ").replace("\t", " ")
if len(latest_submission) > 0:
if latest_submission["version"]:
current_version = " ".join(
Expand All @@ -160,5 +160,7 @@ def get_ontology_list(self) -> None:
outfile.write(
f"{acronym}\t{name}\t{current_version}\t{submission_id}\n"
)
# Wait for half a second to avoid rate limiting
time.sleep(0.5)

logging.info(f"Wrote to {self.output_dir}/{ONTOLOGY_LIST_NAME}")
Loading