[Feature]: Use pydantic validation in observability.py config#26637
[Feature]: Use pydantic validation in observability.py config#26637hmellor merged 21 commits intovllm-project:mainfrom
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run You ask your reviewers to trigger select CI tests on top of Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
There was a problem hiding this comment.
Code Review
This pull request refactors the ObservabilityConfig to use Pydantic validators, which is a good step towards improving configuration clarity and robustness. However, I've identified a critical issue in the parsing logic for collect_detailed_traces that could lead to silent misconfiguration. Additionally, an important validation check for OpenTelemetry dependencies has been removed, which I consider a regression from the previous fail-fast behavior. My review includes suggestions to address both of these points.
688edad to
7c20b90
Compare
💡 Codex Reviewhttps://github.com/vllm-project/vllm/blob/688edaded61796634ff030702a07b6824cb96ff2/vllm/config/observability.py#L107-L116 The new ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. |
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
1c32e22 to
62361cd
Compare
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
Signed-off-by: Sam/Samuel <[email protected]>
Signed-off-by: Sam/Samuel <[email protected]>
Signed-off-by: Samuel Wu <[email protected]>
|
One note, but I've moved the Otherwise, I've applied your suggestions in the most recent commit @hmellor |
Co-authored-by: Harry Mellor <[email protected]> Signed-off-by: Sam/Samuel <[email protected]>
Co-authored-by: Harry Mellor <[email protected]> Signed-off-by: Sam/Samuel <[email protected]>
hmellor
left a comment
There was a problem hiding this comment.
Thanks for the PR, can you:
- move
_parse_collect_detailed_tracesinto the if block and make that an after field validator - make the rest of
__post_init__into an after field validator for otlp_traces_endpoint
vllm/config/observability.py
Outdated
| @field_validator("collect_detailed_traces", mode="before") | ||
| @classmethod | ||
| def _validate_collect_detailed_traces(cls, value: Any) -> list[DetailedTraceModules] | None: | ||
| if value in (None, "", []): | ||
| return None | ||
|
|
||
| items: list[str] = [] | ||
|
|
||
| def add(obj: Any): | ||
| if obj is None: | ||
| return | ||
| elif isinstance(obj, str): | ||
| items.extend(part.strip().lower() for part in obj.split(",")) | ||
| elif isinstance(obj, (list, tuple, set)): | ||
| for x in obj: | ||
| add(x) | ||
| else: | ||
| items.append(str(obj).strip().lower()) | ||
|
|
||
| add(value) | ||
|
|
||
| out: list[str] = [] | ||
| seen: set[str] = set() | ||
| for item in items: | ||
| if item and item not in seen: | ||
| seen.add(item) | ||
| out.append(item) | ||
|
|
||
| if not out: | ||
| return None | ||
| return cast(list[DetailedTraceModules], out) |
There was a problem hiding this comment.
This still isn't quite right. You can change it to an after validator because the input will always pass pydantic's built in validation. We just need a post processing step.
collect_detailed_traces will always be a list[str] or None. The special case is if the list only has one element, and that element is a comma separated list. This is why we split the 0th element in the original implementation.
Signed-off-by: Samuel Wu <[email protected]>
18320bd to
a279fa2
Compare
Signed-off-by: Samuel Wu <[email protected]>
|
Thank you for the feedback @hmellor! I've made the following changes:
Edit: I've reverted |
Signed-off-by: Samuel Wu <[email protected]>
…vllm into pydantic-observability
Signed-off-by: Harry Mellor <[email protected]>
|
Thank you again for the PR, I've pushed a commit that simplifies the logic of the new validators you wrote. It's not worth writing a fancy validator for the comma separated string use case because it's legacy and I hope to deprecate some day. |
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]> Signed-off-by: Alberto Perdomo <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]> Signed-off-by: 0xrushi <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]> Signed-off-by: 0xrushi <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]>
…roject#26637) Signed-off-by: Samuel Wu <[email protected]> Signed-off-by: Sam/Samuel <[email protected]> Signed-off-by: Harry Mellor <[email protected]> Co-authored-by: Harry Mellor <[email protected]>
Part of #26366
show_hidden_metrics_for_versionto ensure proper version formattingotlp_traces_endpointto ensure it starts with either 'http://' or 'https://'collect_detailed_tracesandotlp_traces_endpointPurpose
Test Plan
Test Result
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.