Skip to content
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
28 changes: 27 additions & 1 deletion api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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', ''),
Expand All @@ -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,
}


Expand Down
9 changes: 9 additions & 0 deletions documentation/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,22 @@ 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
{
"status": "ok",
"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,
Expand Down
29 changes: 29 additions & 0 deletions tests/test_status.py
Original file line number Diff line number Diff line change
@@ -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