Commit f7731ec
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
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
0 commit comments