Skip to content

Commit f7731ec

Browse files
git-jxjsjmonson
andauthored
fix(presentation): Correct type hint to fix Pydantic serialization warning (#317)
## Summary This PR fixes a PydanticSerializationUnexpectedValue warning that is raised when generating a benchmark report (e.g., in HTML format). The warning Expected float - serialized value may not be as expected [input_value='p50', input_type=str] occurs because the percentile_rows method in the TabularDistributionSummary class has an incorrect return type hint. The method generates a list of dictionaries, where each dictionary contains a string value for the 'percentile' key (e.g., 'p50') and a float value for the 'value' key. The type hint list[dict[str, float]] incorrectly stated that all dictionary values would be floats. ## Details ## Test Plan guidellm benchmark run --target <any-target> --output-path=benchmarks.html ## Related Issues #314 - Resolves # This fix corrects the type hint for the percentile_rows method to list[dict[str, Union[str, float]]], accurately describing the data being returned. This resolves the serialization warning from Pydantic without changing any runtime logic. Before: 1 def percentile_rows(self) -> list[dict[str, float]]: After: 1 def percentile_rows(self) -> list[dict[str, Union[str, float]]]: - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`) Signed-off-by: xinjun.jiang <[email protected]> Co-authored-by: Samuel Monson <[email protected]>
1 parent 0ce21da commit f7731ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/guidellm/presentation/data_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class TabularDistributionSummary(DistributionSummary):
190190
"""
191191

192192
@computed_field
193-
def percentile_rows(self) -> list[dict[str, float]]:
193+
def percentile_rows(self) -> list[dict[str, Union[str, float]]]:
194194
rows = [
195195
{"percentile": name, "value": value}
196196
for name, value in self.percentiles.model_dump().items()

0 commit comments

Comments
 (0)