Skip to content

Commit 82a381f

Browse files
committed
Replace Request breakdown with generic class
1 parent 5e63061 commit 82a381f

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

src/guidellm/benchmark/benchmark.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import random
22
import uuid
3-
from typing import Any, Dict, List, Literal, Optional, TypeVar, Union
3+
from typing import Any, Dict, Generic, List, Literal, Optional, TypeVar, Union
44

55
from pydantic import Field, computed_field
66

@@ -34,18 +34,38 @@
3434

3535
__all__ = [
3636
"BENCH",
37+
"StatusBreakdown",
3738
"BenchmarkArgs",
3839
"BenchmarkRunStats",
3940
"Benchmark",
4041
"BenchmarkMetrics",
4142
"GenerativeTextResponseStats",
4243
"GenerativeTextErrorStats",
4344
"GenerativeMetrics",
44-
"GenerativeRequestsBreakdown",
4545
"GenerativeBenchmark",
4646
]
4747

4848

49+
SuccessfulT = TypeVar("SuccessfulT")
50+
IncompleteT = TypeVar("IncompleteT")
51+
ErroredT = TypeVar("ErroredT")
52+
class StatusBreakdown(StandardBaseModel, Generic[SuccessfulT, IncompleteT, ErroredT]):
53+
"""
54+
A serializable model representing the breakdown of statistics for a benchmark run
55+
split into successful, incomplete, and errored.
56+
"""
57+
58+
successful: SuccessfulT = Field(
59+
description="Successful",
60+
)
61+
incomplete: IncompleteT = Field(
62+
description="Incomplete",
63+
)
64+
errored: ErroredT = Field(
65+
description="Errored",
66+
)
67+
68+
4969
class BenchmarkArgs(StandardBaseModel):
5070
"""
5171
A serializable model representing the arguments used to specify a benchmark run
@@ -575,23 +595,6 @@ class GenerativeMetrics(BenchmarkMetrics):
575595
)
576596

577597

578-
class GenerativeRequestsBreakdown(StandardBaseModel):
579-
"""
580-
A serializable model representing the breakdown of requests for a generative
581-
benchmark run.
582-
"""
583-
584-
successful: List[GenerativeTextResponseStats] = Field(
585-
description="The list of completed requests.",
586-
)
587-
incomplete: List[GenerativeTextErrorStats] = Field(
588-
description="The list of incomplete requests.",
589-
)
590-
errored: List[GenerativeTextErrorStats] = Field(
591-
description="The list of errored requests.",
592-
)
593-
594-
595598
class GenerativeBenchmark(Benchmark):
596599
"""
597600
A serializable model representing a benchmark run and its results for generative
@@ -652,7 +655,11 @@ class GenerativeBenchmark(Benchmark):
652655
),
653656
)
654657
# Output is ordered so keep this at the end
655-
requests: GenerativeRequestsBreakdown = Field(
658+
requests: StatusBreakdown[
659+
List[GenerativeTextResponseStats],
660+
List[GenerativeTextErrorStats],
661+
List[GenerativeTextErrorStats]
662+
] = Field(
656663
description=(
657664
"The breakdown of requests for the benchmark run including completed, "
658665
"incomplete, and errored requests."
@@ -905,7 +912,7 @@ def from_stats(
905912
],
906913
),
907914
),
908-
requests=GenerativeRequestsBreakdown(
915+
requests=StatusBreakdown(
909916
successful=successful,
910917
incomplete=incomplete,
911918
errored=errored,

0 commit comments

Comments
 (0)