Skip to content

Commit b1bce44

Browse files
committed
List the names of the failing benchmark subworkflows
1 parent 26a6771 commit b1bce44

5 files changed

Lines changed: 62 additions & 6 deletions

File tree

packages/react-ui/src/app/features/benchmark/components/benchmark-wizard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const BenchmarkWizard = ({
8787
const {
8888
runPhase,
8989
runningProgress,
90+
failedWorkflowNames,
9091
isRunPending,
9192
handleRunBenchmark,
9293
handleResetRun,
@@ -174,6 +175,7 @@ export const BenchmarkWizard = ({
174175
result={benchmarkCreateResult}
175176
runPhase={runPhase}
176177
runningProgress={runningProgress ?? undefined}
178+
failedWorkflowNames={failedWorkflowNames}
177179
/>
178180
)}
179181
</WizardStep>

packages/react-ui/src/app/features/benchmark/tests/use-benchmark-run.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ describe('useBenchmarkRun', () => {
136136

137137
expect(result.current.isRunPending).toBe(false);
138138
});
139+
140+
it('should start with empty failedWorkflowNames', () => {
141+
const { result } = renderHook(() =>
142+
useBenchmarkRun(buildBenchmarkCreationResult()),
143+
);
144+
145+
expect(result.current.failedWorkflowNames).toEqual([]);
146+
});
139147
});
140148

141149
describe('handleRunBenchmark', () => {
@@ -255,6 +263,7 @@ describe('useBenchmarkRun', () => {
255263
});
256264

257265
expect(result.current.runPhase).toBe('succeeded');
266+
expect(result.current.failedWorkflowNames).toEqual([]);
258267
});
259268

260269
it('should transition to succeeded_with_failures when some sub-workflows failed', async () => {
@@ -293,6 +302,7 @@ describe('useBenchmarkRun', () => {
293302
});
294303

295304
expect(result.current.runPhase).toBe('succeeded_with_failures');
305+
expect(result.current.failedWorkflowNames).toEqual(['Sub']);
296306
});
297307

298308
it('should transition to failed when status is FAILED', async () => {

packages/react-ui/src/app/features/benchmark/use-benchmark-run.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { benchmarkApi } from './benchmark-api';
1818
export type UseBenchmarkRunResult = {
1919
runPhase: BenchmarkRunPhase;
2020
runningProgress: { completed: number; total: number } | null;
21+
failedWorkflowNames: string[];
2122
isRunPending: boolean;
2223
handleRunBenchmark: () => Promise<void>;
2324
handleResetRun: () => void;
@@ -43,11 +44,23 @@ function mapStatusToRunPhase(
4344
}
4445
}
4546

47+
function getFailedSubWorkflowNames(data: BenchmarkStatusResponse): string[] {
48+
return data.workflows
49+
.filter(
50+
(w) =>
51+
!w.isOrchestrator &&
52+
!w.isCleanup &&
53+
w.runStatus === BenchmarkStatus.FAILED,
54+
)
55+
.map((w) => w.displayName);
56+
}
57+
4658
export const useBenchmarkRun = (
4759
benchmarkCreateResult: BenchmarkCreationResult | null,
4860
): UseBenchmarkRunResult => {
4961
const [runPhase, setRunPhase] = useState<BenchmarkRunPhase>('idle');
5062
const [lastRunId, setLastRunId] = useState<string | undefined>();
63+
const [failedWorkflowNames, setFailedWorkflowNames] = useState<string[]>([]);
5164
const [runCount, setRunCount] = useState(0);
5265

5366
const benchmarkId = benchmarkCreateResult?.benchmarkId ?? null;
@@ -80,6 +93,9 @@ export const useBenchmarkRun = (
8093
setLastRunId(statusData.lastRunId);
8194
}
8295
const newPhase = mapStatusToRunPhase(statusData);
96+
if (newPhase === 'succeeded_with_failures') {
97+
setFailedWorkflowNames(getFailedSubWorkflowNames(statusData));
98+
}
8399
if (newPhase !== null) {
84100
setRunPhase(newPhase);
85101
}
@@ -122,6 +138,7 @@ export const useBenchmarkRun = (
122138
const handleResetRun = () => {
123139
setRunPhase('idle');
124140
setLastRunId(undefined);
141+
setFailedWorkflowNames([]);
125142
};
126143

127144
const runningProgress = useMemo(() => {
@@ -148,6 +165,7 @@ export const useBenchmarkRun = (
148165
return {
149166
runPhase,
150167
runningProgress,
168+
failedWorkflowNames,
151169
isRunPending,
152170
handleRunBenchmark,
153171
handleResetRun,

packages/ui-components/src/components/benchmark/benchmark-ready-step.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,33 @@ import { BenchmarkFailedPhase } from './benchmark-failed-phase';
77
import { BenchmarkRunningPhase } from './benchmark-running-phase';
88
import { BenchmarkWorkflowList } from './benchmark-workflow-list';
99

10+
const FailedWorkflowsList = ({ names }: { names: string[] }) => (
11+
<div className="flex flex-col gap-1 py-2">
12+
<p className="text-sm dark:text-muted-foreground font-medium">
13+
{t('The following workflows failed:')}
14+
</p>
15+
<ul className="list-disc pl-5 text-sm dark:text-muted-foreground">
16+
{names.map((name) => (
17+
<li key={name}>{name}</li>
18+
))}
19+
</ul>
20+
</div>
21+
);
22+
1023
interface BenchmarkReadyStepProps {
1124
providerName: string;
1225
result: BenchmarkCreationResult;
1326
runPhase: BenchmarkRunPhase;
1427
runningProgress?: { completed: number; total: number };
28+
failedWorkflowNames?: string[];
1529
}
1630

1731
export const BenchmarkReadyStep = ({
1832
providerName,
1933
result,
2034
runPhase,
2135
runningProgress,
36+
failedWorkflowNames,
2237
}: BenchmarkReadyStepProps) => {
2338
const subWorkflows = result.workflows.filter(
2439
(w) => !w.isOrchestrator && !w.isCleanup,
@@ -52,12 +67,17 @@ export const BenchmarkReadyStep = ({
5267
{runPhase === 'failed' && <BenchmarkFailedPhase />}
5368

5469
{runPhase === 'succeeded_with_failures' && (
55-
<BenchmarkAnalyticsPhase
56-
provider={providerName}
57-
message={t(
58-
"You can review your Benchmark Report here (it's not final since there are some failed workflows)",
70+
<>
71+
<BenchmarkAnalyticsPhase
72+
provider={providerName}
73+
message={t(
74+
"You can review your Benchmark Report here (it's not final since there are some failed workflows)",
75+
)}
76+
/>
77+
{failedWorkflowNames && failedWorkflowNames.length > 0 && (
78+
<FailedWorkflowsList names={failedWorkflowNames} />
5979
)}
60-
/>
80+
</>
6181
)}
6282

6383
{runPhase === 'succeeded' && (

packages/ui-components/src/stories/benchmark/benchmark-ready-step.stories.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export const RunningWithProgress: ReadyStepStory = {
6767
};
6868
export const Failed: ReadyStepStory = { args: { runPhase: 'failed' } };
6969
export const SucceededWithFailures: ReadyStepStory = {
70-
args: { runPhase: 'succeeded_with_failures' },
70+
args: {
71+
runPhase: 'succeeded_with_failures',
72+
failedWorkflowNames: [
73+
'EC2 Reserved Instances Analysis',
74+
'S3 Storage Optimization',
75+
],
76+
},
7177
};
7278
export const Succeeded: ReadyStepStory = { args: { runPhase: 'succeeded' } };

0 commit comments

Comments
 (0)