diff --git a/api/server.py b/api/server.py index 955193fc..386fd5f1 100755 --- a/api/server.py +++ b/api/server.py @@ -71,6 +71,18 @@ async def status() -> Dict: babel_version = os.environ.get("BABEL_VERSION", "unknown") babel_version_url = os.environ.get("BABEL_VERSION_URL", "") + # Look up the BIOLINK_MODEL_TAG. + # Note: this should be a tag from the Biolink Model repo, e.g. "master" or "v4.3.6". + biolink_model_tag = os.environ.get("BIOLINK_MODEL_TAG", "master") + biolink_model_url = f"https://github.com/biolink/biolink-model/tree/{biolink_model_tag}" + biolink_model_download_url = f"https://raw.githubusercontent.com/biolink/biolink-model/{biolink_model_tag}/biolink-model.yaml" + + # Figure out the NameRes version. + nameres_version = "master" + app_info = get_app_info() + if 'version' in app_info and app_info['version']: + nameres_version = 'v' + app_info['version'] + # We should have a status for name_lookup_shard1_replica_n1. if 'status' in result and 'name_lookup_shard1_replica_n1' in result['status']: core = result['status']['name_lookup_shard1_replica_n1'] @@ -84,6 +96,12 @@ async def status() -> Dict: 'message': 'Reporting results from primary core.', 'babel_version': babel_version, 'babel_version_url': babel_version_url, + 'biolink_model': { + 'tag': biolink_model_tag, + 'url': biolink_model_url, + 'download_url': biolink_model_download_url, + }, + 'nameres_version': nameres_version, 'startTime': core['startTime'], 'numDocs': index.get('numDocs', ''), 'maxDoc': index.get('maxDoc', ''), @@ -96,7 +114,15 @@ async def status() -> Dict: else: return { 'status': 'error', - 'message': 'Expected core not found.' + 'message': 'Expected core not found.', + 'babel_version': babel_version, + 'babel_version_url': babel_version_url, + 'biolink_model': { + 'tag': biolink_model_tag, + 'url': biolink_model_url, + 'download_url': biolink_model_download_url, + }, + 'nameres_version': nameres_version, } diff --git a/documentation/API.md b/documentation/API.md index fc0703a3..57bcbdea 100644 --- a/documentation/API.md +++ b/documentation/API.md @@ -310,6 +310,9 @@ POST /synonyms with body: Returns the status of the service. Most importantly, this returns the [Babel](https://github.com/NCATSTranslator/Babel) version and changelog URL, which can be used to determine which version of Babel is currently loaded in this service. +It also includes the NameRes version (also visible in the OpenAPI documentation) +and the Biolink Model version used to build the Solr database, as well as bunch of information from the underlying +Solr database. ```json { @@ -317,6 +320,12 @@ version and changelog URL, which can be used to determine which version of Babel "message": "Reporting results from primary core.", "babel_version": "2025sep1", "babel_version_url": "https://github.com/ncatstranslator/Babel/blob/master/releases/2025sep1.md", + "biolink_model": { + "tag": "v4.2.6-rc5", + "url": "https://github.com/biolink/biolink-model/tree/v4.2.6-rc5", + "download_url": "https://raw.githubusercontent.com/biolink/biolink-model/v4.2.6-rc5/biolink-model.yaml" + }, + "nameres_version": "v1.5.1", "startTime": "2025-12-19T11:53:09.638Z", "numDocs": 425583391, "maxDoc": 425586610, diff --git a/tests/test_status.py b/tests/test_status.py new file mode 100644 index 00000000..b48ddc07 --- /dev/null +++ b/tests/test_status.py @@ -0,0 +1,29 @@ +import logging + +from api.server import app +from fastapi.testclient import TestClient + +# Turn on debugging for tests. +logging.basicConfig(level=logging.DEBUG) + +def test_status(): + client = TestClient(app) + response = client.get("/status") + status = response.json() + + assert status['status'] == 'ok' + assert status['message'] != '' + assert 'babel_version' in status + assert 'babel_version_url' in status + assert 'biolink_model' in status + assert 'tag' in status['biolink_model'] + assert 'nameres_version' in status + assert status['version'] > 1 + assert status['size'] != '' + assert status['startTime'] + + # Count the specific number of test documents we load. + assert status['numDocs'] == 89 + assert status['maxDoc'] == 89 + assert status['deletedDocs'] == 0 +