fix(presentation): Correct type hint to fix Pydantic serialization warning #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 --output-path=benchmarks.html
Related Issues
#314
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]]]:
Use of AI
## WRITTEN BY AI ##
)