-
Notifications
You must be signed in to change notification settings - Fork 322
feat: add /v1/test endpoint to the retriever service #2184
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
base: main
Are you sure you want to change the base?
Changes from all commits
b6b9e1e
3412827
9233869
c2743c8
68b2402
8b443b2
63391f0
3a8a9bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. | ||||||
| # All rights reserved. | ||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||
|
|
||||||
| """Test endpoint for the retriever service. | ||||||
|
|
||||||
| Provides a lightweight, no-dependency health-check route that validates | ||||||
| the Python runtime and the current service mode are reachable at all. | ||||||
| """ | ||||||
|
|
||||||
| from __future__ import annotations | ||||||
|
|
||||||
| import logging | ||||||
| import platform | ||||||
| import sys | ||||||
|
|
||||||
| from fastapi import APIRouter, Request | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
|
|
||||||
| router = APIRouter(tags=["test"], include_in_schema=True) | ||||||
|
|
||||||
|
|
||||||
| @router.get("/test", summary="Health-check that validates the Python runtime") | ||||||
| async def test(request: Request) -> dict: | ||||||
| """Return a JSON blob describing the current process environment. | ||||||
|
|
||||||
| Response shape:: | ||||||
|
|
||||||
| { | ||||||
| "status": "ok", | ||||||
| "mode": "gateway" | "realtime" | "batch" | "standalone", | ||||||
| "python": "3.12.1+linux", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/service/routers/test.py
Line: 33
Comment:
The docstring example shows `"3.12.1+linux"` but the actual runtime string produced by the code is `"3.12.1; Linux"` (note the semicolon separator and capital-L `Linux` from `platform.system()`). A caller validating the response against the documented shape would be misled by this mismatch.
```suggestion
"python": "3.12.1; Linux",
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||
| } | ||||||
|
|
||||||
| Intended for cluster probes, load-balancer heart-beats, and manual | ||||||
| smoke-tests -- it has no external dependencies (no DB, no pipeline | ||||||
| pool, no media binaries). | ||||||
| """ | ||||||
| config = getattr(request.app.state, "config", None) | ||||||
| mode = config.mode if config is not None else "unknown" | ||||||
| runtime = f"{sys.version.split()[0]}; {'/'.join(platform.system().split())}" | ||||||
| return {"status": "ok", "mode": mode, "python": runtime} | ||||||
|
Comment on lines
+1
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Prompt To Fix With AIThis is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/service/routers/test.py
Line: 1-43
Comment:
**Missing test coverage for new endpoint**
The `test-mirrors-source-structure` and `test-coverage-new-code` rules both require a corresponding test file for every new source module. This router adds a new public API endpoint but the PR includes no tests — not even a basic happy-path check that `GET /v1/test` returns `{"status": "ok"}`. Other routers in the service (e.g. `admin`) have corresponding tests under `tests/service_tests/`. A missing test means regressions in the `mode` or `python` field (e.g., `config` not being set on `app.state`) go undetected.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dictis unparameterized. Thetype-hints-public-apirule requires complete type annotations on all public interfaces. Since every key and value in the response is astr, usedict[str, str].Prompt To Fix With AI