-
Notifications
You must be signed in to change notification settings - Fork 54
Docstrings for endpoints handlers #375
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
Docstrings for endpoints handlers #375
Conversation
WalkthroughDocstrings were expanded across multiple endpoint handlers to describe request methods, return types, and behaviors. No code logic, signatures, or return types changed. Updates include authorized, config, info, metrics, and multiple health-related functions, clarifying responses like readiness/liveness status and metrics output. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (5)
src/app/endpoints/authorized.py (1)
36-44: Docstring clarity: add Parameters/Responses for completenessConsider enriching the docstring with explicit parameter and response details to mirror the declared FastAPI responses and the Depends-injected auth tuple.
Suggested docstring tweak:
@@ - Handle request to the /authorized endpoint. - - Process POST requests to the /authorized endpoint, returning - the authenticated user's ID and username. - - Returns: - AuthorizedResponse: Contains the user ID and username of the authenticated user. + Handle request to the /authorized endpoint. + + Process POST requests to /authorized and return the authenticated user's + ID and username. + + Parameters: + auth (tuple[str, str, Any]): Injected via Depends(auth_dependency). + Contains (user_id, username, token). The token is ignored. + + Responses: + 200: AuthorizedResponse — The user is logged in and authorized. + 400: UnauthorizedResponse — Missing or invalid credentials. + 403: ForbiddenResponse — Authenticated but not authorized. + + Returns: + AuthorizedResponse: Contains the user ID and username of the authenticated user.Nit: Semantically, many APIs use 401 for missing/invalid credentials; you may want to consider that in a follow-up PR.
src/app/endpoints/metrics.py (1)
17-26: Tighten wording; call out Prometheus text exposition formatMinor grammar and precision improvements below.
@@ - Process GET requests to the /metrics endpoint, returning the - latest Prometheus metrics in form of a plain text. + Process GET requests to /metrics and return the latest Prometheus metrics + in the Prometheus text exposition format (text/plain; version=0.0.4). @@ - Initializes model metrics on the first request if not already - set up, then responds with the current metrics snapshot in - Prometheus format. + Initializes model metrics on the first request if not already set up, + then responds with the current metrics snapshot.src/app/endpoints/config.py (1)
60-68: Grammar/style nit: maintain imperative voiceSmall consistency fix to avoid mixing imperative with third person.
@@ - Process GET requests to the /config endpoint and returns the - current service configuration. + Process GET requests to /config and return the current service configuration.src/app/endpoints/health.py (2)
26-33: Augment docstring with source of status valuesAdd a short note that status values come from the HealthStatus enum and that message can be empty, matching current behavior.
@@ - Returns: - list[ProviderHealthStatus]: A list containing the health - status of each provider. If provider health cannot be - determined, returns a single entry indicating an error. + Returns: + list[ProviderHealthStatus]: A list containing the health status of each + provider. If provider health cannot be determined, returns a single + entry indicating an error. + + Notes: + - ProviderHealthStatus.status values originate from + llama_stack.providers.datatypes.HealthStatus. + - The message field may be empty.
76-82: Clarify readiness semantics for not_implemented providersReflect the in-code behavior that not_implemented is not treated as unhealthy.
@@ - If any provider reports an error status, responds with HTTP 503 - and details of unhealthy providers; otherwise, indicates the - service is ready. + If any provider reports an error status, responds with HTTP 503 and details + of unhealthy providers; otherwise, indicates the service is ready. + + Notes: + - Providers reporting a not_implemented status are not considered + unhealthy for readiness purposes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/app/endpoints/authorized.py(1 hunks)src/app/endpoints/config.py(1 hunks)src/app/endpoints/health.py(3 hunks)src/app/endpoints/info.py(1 hunks)src/app/endpoints/metrics.py(1 hunks)
🔇 Additional comments (2)
src/app/endpoints/info.py (1)
26-34: LGTM — concise and accurate docstringThe description and return type are clear and match the handler behavior.
src/app/endpoints/health.py (1)
116-121: LGTM — succinct and accurate liveness docstringMatches the handler behavior; no further changes needed.
Description
Docstrings for endpoints handlers
Type of change
Summary by CodeRabbit