Skip to content

feat: add /v1/test endpoint to the retriever service#2184

Open
jdye64 wants to merge 8 commits into
NVIDIA:mainfrom
jdye64:feat/v1-test-endpoint
Open

feat: add /v1/test endpoint to the retriever service#2184
jdye64 wants to merge 8 commits into
NVIDIA:mainfrom
jdye64:feat/v1-test-endpoint

Conversation

@jdye64
Copy link
Copy Markdown
Collaborator

@jdye64 jdye64 commented May 31, 2026

Summary

  • Add a lightweight, dep-free /v1/test health-check route to the retriever service FastAPI app
  • Returns JSON with status, mode, and Python runtime info (version, OS)
  • New file: nemo_retriever/service/routers/test.py
  • Wired into app.py under the /v1 prefix

Test Plan

  • Lint passes

jdye64 and others added 8 commits May 6, 2026 11:03
upload-artifact flattens nemo_retriever/dist into ./dist on download;
use find instead of ./dist/nemo_retriever/dist/*. Re-run failed jobs
does not pick up workflow changes — dispatch a new run after merging.
- New router module routes/test.py with a dep-free health-check route
- Returns status, mode, and Python runtime info
- Wired into app.py under /v1 prefix (no external dependencies)
@jdye64 jdye64 requested review from a team as code owners May 31, 2026 23:18
@jdye64 jdye64 requested a review from edknv May 31, 2026 23:18
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 31, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 31, 2026

Greptile Summary

This PR adds a lightweight /v1/test health-check endpoint to the retriever service FastAPI app and improves a comment in the PyPI publish workflow. The new router reads the service mode from app.state.config and returns Python runtime info with no external dependencies.

  • routers/test.py: New router returning {\"status\", \"mode\", \"python\"}; follows SPDX/module-docstring conventions but lacks any unit tests, uses an unparameterized -> dict return type, and the docstring example (\"3.12.1+linux\") does not match the actual output format (\"3.12.1; Linux\").
  • app.py: Additive one-liner wiring test.router under /v1 — mirrors how all other routers are registered, no concerns.
  • reusable-pypi-publish.yml: Comment-only clarification, no functional change.

Confidence Score: 3/5

The new endpoint is additive and has no external dependencies, but ships without any tests despite touching a public API surface.

The router itself is simple and the wiring in app.py is clean, but the new /v1/test endpoint has no corresponding test file — a clear gap given the repo's test-coverage rules. The docstring also documents the response format incorrectly, which would mislead anyone writing integration assertions against it.

nemo_retriever/src/nemo_retriever/service/routers/test.py — needs tests and type annotation / docstring corrections before merge.

Important Files Changed

Filename Overview
nemo_retriever/src/nemo_retriever/service/routers/test.py New /v1/test health-check router; missing unit tests, unparameterized return type, and docstring example mismatches actual runtime string format.
nemo_retriever/src/nemo_retriever/service/app.py Wires the new test router into the FastAPI app under the /v1 prefix alongside existing routers; change is additive and follows existing patterns.
.github/workflows/reusable-pypi-publish.yml Comment-only update clarifying why wheels land directly under ./dist/ after upload-artifact strips the common parent; no functional change.

Sequence Diagram

sequenceDiagram
    participant Probe as Cluster Probe / LB
    participant App as FastAPI App (app.py)
    participant Router as test.router (/v1/test)
    participant State as app.state.config

    Probe->>App: GET /v1/test
    App->>Router: route to test()
    Router->>State: getattr(request.app.state, "config", None)
    State-->>Router: ServiceConfig (or None)
    Router-->>App: "{"status": "ok", "mode": "...", "python": "..."}"
    App-->>Probe: 200 OK JSON response
Loading
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
nemo_retriever/src/nemo_retriever/service/routers/test.py:1-43
**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.

### Issue 2 of 3
nemo_retriever/src/nemo_retriever/service/routers/test.py:25
The return annotation `dict` is unparameterized. The `type-hints-public-api` rule requires complete type annotations on all public interfaces. Since every key and value in the response is a `str`, use `dict[str, str]`.

```suggestion
async def test(request: Request) -> dict[str, str]:
```

### Issue 3 of 3
nemo_retriever/src/nemo_retriever/service/routers/test.py:33
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",
```

Reviews (1): Last reviewed commit: "feat: add /v1/test endpoint to the retri..." | Re-trigger Greptile

Comment on lines +1 to +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",
}

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}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Prompt To Fix With AI
This 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!



@router.get("/test", summary="Health-check that validates the Python runtime")
async def test(request: Request) -> dict:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The return annotation dict is unparameterized. The type-hints-public-api rule requires complete type annotations on all public interfaces. Since every key and value in the response is a str, use dict[str, str].

Suggested change
async def test(request: Request) -> dict:
async def test(request: Request) -> dict[str, str]:
Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/service/routers/test.py
Line: 25

Comment:
The return annotation `dict` is unparameterized. The `type-hints-public-api` rule requires complete type annotations on all public interfaces. Since every key and value in the response is a `str`, use `dict[str, str]`.

```suggestion
async def test(request: Request) -> dict[str, str]:
```

How can I resolve this? If you propose a fix, please make it concise.

{
"status": "ok",
"mode": "gateway" | "realtime" | "batch" | "standalone",
"python": "3.12.1+linux",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
"python": "3.12.1+linux",
"python": "3.12.1; Linux",
Prompt To Fix With AI
This 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant