Skip to content

Add openapi_version and backend to /status output - #392

Merged
gaurav merged 7 commits into
mainfrom
add-backend-and-version-to-status
Jul 15, 2026
Merged

gaurav merged 7 commits into
mainfrom
add-backend-and-version-to-status

Conversation

@gaurav

@gaurav gaurav commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #377.

What

Add two values to the top of the /status output:

  • openapi_version — the app's OpenAPI info.version (currently 2.4.1), from app.openapi_schema["info"]["version"]
  • backend — currently always "redis"; a hook for reporting other backends later

Tests

  • tests/frontend/test_status.py mocks the 7 Redis dbs and asserts both new keys.
  • Also reorganizes the frontend tests under tests/frontend/ (a follow-up can move the loader tests into tests/loader/). Shared helpers/, resources/, and conftest.py stay at tests/.

🤖 Generated with Claude Code

gaurav and others added 2 commits July 15, 2026 07:06
Closes #377. Surface the app's OpenAPI info.version and a backend key
(currently always "redis") at the top of /status.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Group the frontend (server/normalizer) tests under tests/frontend/,
leaving the loader tests at tests/ for a future tests/loader/ move.
Relative imports (..helpers) and resources paths (parent.parent)
updated for the new depth; shared helpers/, resources/, and conftest.py
stay at tests/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
gaurav and others added 5 commits July 15, 2026 07:08
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The /status output now surfaces the app version as "version" (e.g.
"v2.4.1") rather than a separate "openapi_version" key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… CI --ignore

pytestmark = pytest.mark.skip travels with the file, so it survives moves
(e.g. tests/ -> tests/frontend/) instead of relying on the workflow to keep
--ignore paths in sync.
@gaurav
gaurav merged commit 1c1dcf1 into main Jul 15, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in NodeNorm sprints Jul 15, 2026
@gaurav
gaurav deleted the add-backend-and-version-to-status branch July 15, 2026 11:20
gaurav added a commit to NCATSTranslator/NameResolution that referenced this pull request Nov 10, 2026
… stats under `solr` (#304)

This PR adds `backend` and an API `version` to `/status`, matching
NodeNorm's `/status` (NCATSTranslator/NodeNormalization#392). Until now,
nothing machine-readable said whether a NameRes `/status` came from this
Solr implementation or from the Elasticsearch-backed one at
[biothings/NameResolutionAPI](https://github.com/biothings/NameResolutionAPI).
The two differed only by a word of prose in `message`. That gap is what
stopped TranslatorSRI/babel-validation from pinning a NameRes target to
its expected backend.

**Breaking change:** everything `/status` reads from Solr now sits in a
`solr` object rather than at the top level. That covers `startTime`,
`numDocs`, `maxDoc`, `deletedDocs`, `segmentCount`, `lastModified` and
`size`, plus the Solr index version, which was the top-level `version`
and is now `solr.version`. The freed top-level `version` is the API
version.

Closes #296.

## The calls worth overruling

- **A `solr` object, not a renamed `index_version`.** The API version
needed the top-level `version`, so the Solr index version had to move.
Renaming it in place would have fixed only that one key. With a `solr`
object, consumers adjust once, the key is named after `backend`'s value,
and backend detail can't collide with the service's own keys again. It
is also the layout the `improve-performance` branch already uses
(deployed as `release-v1.5.2-with-metrics`). That branch's JVM, OS and
cache stats can therefore land in the same object without a second
break. babel-validation's `trim_status()` already reads `raw["solr"]`
first.
- **`solr.version` keeps Solr's own name** for the index version
counter, as on `improve-performance`, rather than `solr.index_version`.
- **`solr.core`** is new: the name of the core actually reported on.
Because of the single-core fallback, it is not always `SOLR_CORE`. Older
cloud-mode backups call it `name_lookup_shard1_replica_n1`.
- **`version` comes from `get_app_info()`, not `app.openapi_schema`.**
NodeNorm reads the latter, but here it is `None` until the first request
to `/openapi.json` (#294), so a fresh process would report `"unknown"`.
- **Both branches report `backend` and `version`.** The error branch
(`Expected core not found.`) is what a mis-pointed deployment returns,
which is exactly when a caller needs to know which NameRes it reached.
The shared keys are built once as `common` and spread into each return,
so the two can't drift. The error branch has no `solr` object.

## What's here

| key | value |
|---|---|
| `backend` | always `"solr"`; the ES NameRes reports `"elasticsearch"`
|
| `version` | the OpenAPI `info.version` verbatim (`"1.7.0"`) |
| `solr` | `core`, `startTime`, `numDocs`, `maxDoc`, `deletedDocs`,
`version`, `segmentCount`, `lastModified`, `size` |

`nameres_version` (`"v1.7.0"`) is unchanged.
[API.md](https://github.com/NCATSTranslator/NameResolution/blob/639a7a2/documentation/API.md#status)
documents the new shape, with an example. A [CLAUDE.md
gotcha](https://github.com/NCATSTranslator/NameResolution/blob/639a7a2/CLAUDE.md#gotchas)
records why Solr fields must not go back to the top level.

`tests/test_status.py` checks `version` against `/openapi.json`'s
`info.version` rather than a literal, so the two are tested to be
identical. It also asserts that none of the old top-level Solr keys
remain, so a partial revert fails.

## What it deliberately does not do

It doesn't fetch any more from Solr. JVM, OS and cache stats need extra
Solr calls and a `?full=true` switch; that is `improve-performance`'s
work, and this PR only gives it a place to land.

## Verification

`python -m pytest tests/` passes in full (50-odd tests) on 639a7a2
against a local Solr 9.10 with the 89-document test index. I also
checked three mocked Solr responses by hand:
- two cores: the error branch, with `backend` and `version` and no
`solr` object
- a single `name_lookup_shard1_replica_n1` core: `solr.core` names it
- a sparse, still-initializing core: blank counts, not a 500

## Before merging

- `api/resources/openapi.yml` is still at `1.7.0`, and API.md dates the
move to v1.8.0. Bump it when the release is cut.
- Follow-up in TranslatorSRI/babel-validation, not blocking this PR: its
comment "under solr before v1.7, at the top level from v1.7 on" goes
stale. It could also start reading NameRes's top-level `version`, now
that it is a release rather than the index counter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add backend and version to /status

1 participant