Skip to content

Commit 12147ce

Browse files
committed
add dots with tooltip to metric summary line charts
Signed-off-by: dalthecow <[email protected]>
1 parent 000b39e commit 12147ce

File tree

7 files changed

+73
-9
lines changed

7 files changed

+73
-9
lines changed

src/guidellm/presentation/data_models.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from pydantic import BaseModel, computed_field
77

8+
from guidellm.scheduler.strategy import SchedulingStrategy
9+
810
if TYPE_CHECKING:
911
from guidellm.benchmark.benchmark import GenerativeBenchmark
1012

@@ -212,11 +214,29 @@ class BenchmarkDatum(BaseModel):
212214
ttft: TabularDistributionSummary
213215
throughput: TabularDistributionSummary
214216
time_per_request: TabularDistributionSummary
217+
strategy_display_str: str
218+
219+
@classmethod
220+
def get_strategy_display_str(cls, strategy: SchedulingStrategy):
221+
strategy_type = strategy if isinstance(strategy, str) else strategy.type_
222+
strategy_instance = (
223+
strategy if isinstance(strategy, SchedulingStrategy) else None
224+
)
225+
226+
if strategy_type == "concurrent":
227+
rate = f"@{strategy.streams}" if strategy_instance else "@##" # type: ignore[attr-defined]
228+
elif strategy_type in ("constant", "poisson"):
229+
rate = f"@{strategy.rate:.2f}" if strategy_instance else "@#.##" # type: ignore[attr-defined]
230+
else:
231+
rate = ""
232+
return f"{strategy_type}{rate}"
215233

216234
@classmethod
217235
def from_benchmark(cls, bm: "GenerativeBenchmark"):
236+
rps = bm.metrics.requests_per_second.successful.mean
218237
return cls(
219-
requests_per_second=bm.metrics.requests_per_second.successful.mean,
238+
strategy_display_str=cls.get_strategy_display_str(bm.args.strategy),
239+
requests_per_second=rps,
220240
itl=TabularDistributionSummary.from_distribution_summary(
221241
bm.metrics.inter_token_latency_ms.successful
222242
),

src/ui/lib/components/Charts/MetricLine/MetricLine.component.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { useTheme } from '@mui/material';
2-
import { ResponsiveLine } from '@nivo/line';
1+
import { Typography, useTheme } from '@mui/material';
2+
import { PointTooltipProps, ResponsiveLine } from '@nivo/line';
3+
import { BasicTooltip } from '@nivo/tooltip';
34
import React, { FC } from 'react';
45

56
import { useColor } from '@/lib/hooks/useColor';
@@ -49,11 +50,30 @@ export const Component: FC<MetricLineProps> = ({
4950
reverse: false,
5051
};
5152
}
53+
type PointTooltipPropsWithLabel = PointTooltipProps & {
54+
point: {
55+
data: {
56+
label: string;
57+
};
58+
};
59+
};
5260

5361
return (
5462
<ResponsiveLine
5563
curve="monotoneX"
5664
data={data}
65+
tooltip={(point) => (
66+
<BasicTooltip
67+
id={
68+
<Typography variant="body2">
69+
{(point as PointTooltipPropsWithLabel).point.data.label}
70+
</Typography>
71+
}
72+
color={point.point.color}
73+
enableChip={true}
74+
/>
75+
)}
76+
pointSize={10}
5777
colors={[selectedColor]}
5878
margin={{ top: 20, right: 10, bottom: 20, left: 35.5 }}
5979
xScale={{ type: 'linear', min: minX }}
@@ -92,7 +112,6 @@ export const Component: FC<MetricLineProps> = ({
92112
}}
93113
enableGridX={false}
94114
enableGridY={false}
95-
pointSize={0}
96115
useMesh={true}
97116
layers={[
98117
CustomAxes,
@@ -115,6 +134,9 @@ export const Component: FC<MetricLineProps> = ({
115134
),
116135
'axes',
117136
'lines',
137+
'points',
138+
'markers',
139+
'mesh',
118140
]}
119141
theme={lineTheme}
120142
/>

src/ui/lib/components/MetricsSummary/MetricsSummary.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const Component = () => {
102102
return (
103103
<>
104104
<BlockHeader label="Metrics Summary" />
105-
<MetricsSummaryContainer container>
105+
<MetricsSummaryContainer sx={{ overflow: 'visible' }} container>
106106
<HeaderLeftCell item xs={9}>
107107
<Box display="flex" flexDirection="row" justifyContent="space-between">
108108
<Typography variant="h6" color="surface.onSurface" mb={2}>

src/ui/lib/store/benchmarksWindowData.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const benchmarksScript = `window.benchmarks = [
22
{
3+
strategyDisplayStr: "synchronous",
34
requestsPerSecond: 11.411616848282272,
45
itl: {
56
mean: 8.758024845683707,
@@ -171,6 +172,7 @@ export const benchmarksScript = `window.benchmarks = [
171172
},
172173
},
173174
{
175+
strategyDisplayStr: "[email protected]",
174176
requestsPerSecond: 36.289181300710815,
175177
itl: {
176178
mean: 588.0161376137819,
@@ -342,6 +344,7 @@ export const benchmarksScript = `window.benchmarks = [
342344
},
343345
},
344346
{
347+
strategyDisplayStr: "[email protected]",
345348
requestsPerSecond: 20.752070927855794,
346349
itl: {
347350
mean: 116.28360712595156,
@@ -513,6 +516,7 @@ export const benchmarksScript = `window.benchmarks = [
513516
},
514517
},
515518
{
519+
strategyDisplayStr: "[email protected]",
516520
requestsPerSecond: 26.81917480361788,
517521
itl: {
518522
mean: 299.7306064613554,
@@ -684,6 +688,7 @@ export const benchmarksScript = `window.benchmarks = [
684688
},
685689
},
686690
{
691+
strategyDisplayStr: "[email protected]",
687692
requestsPerSecond: 26.823988819498975,
688693
itl: {
689694
mean: 683.8011571339198,
@@ -855,6 +860,7 @@ export const benchmarksScript = `window.benchmarks = [
855860
},
856861
},
857862
{
863+
strategyDisplayStr: "[email protected]",
858864
requestsPerSecond: 24.50047903792646,
859865
itl: {
860866
mean: 742.9258901891964,
@@ -1026,6 +1032,7 @@ export const benchmarksScript = `window.benchmarks = [
10261032
},
10271033
},
10281034
{
1035+
strategyDisplayStr: "[email protected]",
10291036
requestsPerSecond: 25.617829792196602,
10301037
itl: {
10311038
mean: 663.3098317044122,
@@ -1197,6 +1204,7 @@ export const benchmarksScript = `window.benchmarks = [
11971204
},
11981205
},
11991206
{
1207+
strategyDisplayStr: "[email protected]",
12001208
requestsPerSecond: 37.02892550982192,
12011209
itl: {
12021210
mean: 606.4144710877113,
@@ -1368,6 +1376,7 @@ export const benchmarksScript = `window.benchmarks = [
13681376
},
13691377
},
13701378
{
1379+
strategyDisplayStr: "[email protected]",
13711380
requestsPerSecond: 37.29183354201869,
13721381
itl: {
13731382
mean: 603.3237551205925,
@@ -1539,6 +1548,7 @@ export const benchmarksScript = `window.benchmarks = [
15391548
},
15401549
},
15411550
{
1551+
strategyDisplayStr: "throughput",
15421552
requestsPerSecond: 37.45318312972309,
15431553
itl: {
15441554
mean: 600.7204526769262,

src/ui/lib/store/slices/benchmarks/benchmarks.interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface BenchmarkMetrics {
2727

2828
export interface Benchmark extends BenchmarkMetrics {
2929
requestsPerSecond: number;
30+
strategyDisplayStr: string;
3031
}
3132

3233
export type Benchmarks = Benchmark[];

src/ui/lib/store/slices/benchmarks/benchmarks.selectors.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export const selectMetricsSummaryLineData = createSelector(
1818
?.slice()
1919
?.sort((bm1, bm2) => (bm1.requestsPerSecond > bm2.requestsPerSecond ? 1 : -1));
2020
const selectedPercentile = sloState.enforcedPercentile;
21-
22-
const lineData: { [K in keyof BenchmarkMetrics]: Point[] } = {
21+
interface PointWithLabel extends Point {
22+
label: string;
23+
}
24+
const lineData: { [K in keyof BenchmarkMetrics]: PointWithLabel[] } = {
2325
ttft: [],
2426
itl: [],
2527
timePerRequest: [],
@@ -32,14 +34,15 @@ export const selectMetricsSummaryLineData = createSelector(
3234
'throughput',
3335
];
3436
metrics.forEach((metric) => {
35-
const data: Point[] = [];
37+
const data: PointWithLabel[] = [];
3638
sortedByRPS?.forEach((benchmark) => {
3739
const percentile = benchmark[metric].percentileRows.find(
3840
(p) => p.percentile === selectedPercentile
3941
);
4042
data.push({
4143
x: benchmark.requestsPerSecond,
4244
y: percentile?.value ?? 0,
45+
label: benchmark.strategyDisplayStr,
4346
});
4447
});
4548

tests/unit/presentation/test_data_models.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

3-
from guidellm.presentation.data_models import Bucket
3+
from guidellm.presentation.data_models import BenchmarkDatum, Bucket
4+
from tests.unit.mock_benchmark import mock_generative_benchmark
45

56

67
@pytest.mark.smoke
@@ -18,3 +19,10 @@ def test_bucket_from_data():
1819
assert buckets[1].value == 8.0
1920
assert buckets[1].count == 5
2021
assert bucket_width == 1
22+
23+
24+
@pytest.mark.smoke
25+
def test_from_benchmark_includes_strategy_display_str():
26+
mock_bm = mock_generative_benchmark()
27+
bm = BenchmarkDatum.from_benchmark(mock_bm)
28+
assert bm.strategy_display_str == "synchronous"

0 commit comments

Comments
 (0)