Skip to content

Commit e38834c

Browse files
committed
Always pass perf filters to card artifacts call for correct benchmark counts
Signed-off-by: manaswinidas <dasmanaswini10@gmail.com>
1 parent bb8e5d6 commit e38834c

File tree

3 files changed

+94
-10
lines changed

3 files changed

+94
-10
lines changed

clients/ui/frontend/src/__tests__/cypress/cypress/support/interceptHelpers/modelCatalog.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,57 @@ export const interceptPerformanceArtifactsList = (overrideArtifacts?: {
347347
).as('getCatalogSourceModelArtifacts');
348348
};
349349

350+
/**
351+
* Intercepts performance artifacts with dynamic response based on filterQuery presence.
352+
* Returns 3 artifacts when filterQuery is present, 5 when absent.
353+
* Used to test that perf filters are passed regardless of toggle state.
354+
*/
355+
export const interceptPerformanceArtifactsWithFilterCheck = (): void => {
356+
cy.intercept(
357+
{
358+
method: 'GET',
359+
url: new RegExp(
360+
`/model-registry/api/${MODEL_CATALOG_API_VERSION}/model_catalog/sources/.*/performance_artifacts/.*`,
361+
),
362+
},
363+
(req) => {
364+
const hasFilterQuery = req.url.includes('filterQuery');
365+
// Return different counts based on whether filterQuery is present
366+
const artifactCount = hasFilterQuery ? 3 : 5;
367+
const items = Array.from({ length: artifactCount }, (_, i) =>
368+
mockCatalogPerformanceMetricsArtifact({
369+
customProperties: {
370+
hardware_configuration: {
371+
metadataType: ModelRegistryMetadataType.STRING,
372+
string_value: `${i + 1} x H100-80`,
373+
},
374+
ttft_p90: {
375+
metadataType: ModelRegistryMetadataType.DOUBLE,
376+
double_value: 50 + i * 10,
377+
},
378+
replicas: {
379+
metadataType: ModelRegistryMetadataType.INT,
380+
int_value: String(i + 1),
381+
},
382+
use_case: {
383+
metadataType: ModelRegistryMetadataType.STRING,
384+
string_value: 'chatbot',
385+
},
386+
},
387+
}),
388+
);
389+
req.reply(
390+
mockModArchResponse({
391+
items,
392+
size: artifactCount,
393+
pageSize: 10,
394+
nextPageToken: '',
395+
}),
396+
);
397+
},
398+
).as('getCatalogSourceModelArtifacts');
399+
};
400+
350401
/**
351402
* Intercepts the /artifacts/ endpoint (used to determine if tabs should show)
352403
* @param overrideArtifacts - Optional override for the artifacts response (e.g., empty list)

clients/ui/frontend/src/__tests__/cypress/cypress/tests/mocked/modelCatalog/modelCatalogCard.cy.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { modelCatalog } from '~/__tests__/cypress/cypress/pages/modelCatalog';
22
import {
33
setupModelCatalogIntercepts,
4+
interceptPerformanceArtifactsWithFilterCheck,
45
type ModelCatalogInterceptOptions,
56
} from '~/__tests__/cypress/cypress/support/interceptHelpers/modelCatalog';
67
import { PERFORMANCE_FILTER_TEST_IDS } from '~/__tests__/cypress/cypress/support/constants';
@@ -169,6 +170,41 @@ describe('ModelCatalogCard Component', () => {
169170
});
170171
});
171172
});
173+
174+
describe('Benchmark count consistency', () => {
175+
it('should show same benchmark count with toggle OFF as with toggle ON', () => {
176+
// Use dynamic mock that returns different counts based on filterQuery presence
177+
// Returns 3 artifacts when filterQuery present, 5 when absent
178+
setupModelCatalogIntercepts({ useValidatedModel: true });
179+
interceptPerformanceArtifactsWithFilterCheck();
180+
181+
modelCatalog.visit();
182+
183+
// Turn toggle ON to apply default filters
184+
modelCatalog.togglePerformanceView();
185+
modelCatalog.findLoadingState().should('not.exist');
186+
187+
// Verify benchmark count with toggle ON (shows "X of 3 benchmarks")
188+
cy.wait('@getCatalogSourceModelArtifacts');
189+
modelCatalog.findFirstModelCatalogCard().within(() => {
190+
modelCatalog.findValidatedModelBenchmarksCount().should('contain.text', '3 benchmarks');
191+
});
192+
193+
// Turn toggle OFF - should still show same count (filters still passed)
194+
modelCatalog.togglePerformanceView();
195+
modelCatalog.findLoadingState().should('not.exist');
196+
197+
// Verify benchmark count with toggle OFF (shows "View 3 benchmarks")
198+
cy.wait('@getCatalogSourceModelArtifacts');
199+
modelCatalog.findFirstModelCatalogCard().within(() => {
200+
// With the fix: filterQuery is passed, so count is 3
201+
// Without the fix: filterQuery not passed, count would be 5
202+
modelCatalog
203+
.findValidatedModelBenchmarkLink()
204+
.should('contain.text', 'View 3 benchmarks');
205+
});
206+
});
207+
});
172208
});
173209

174210
/**

clients/ui/frontend/src/app/pages/modelCatalog/components/ModelCatalogCardBody.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,18 @@ const ModelCatalogCardBody: React.FC<ModelCatalogCardBodyProps> = ({
6262
};
6363

6464
// Get performance-specific filter params for the /performance_artifacts endpoint
65-
// Only apply performance filters when toggle is ON
66-
const targetRPS = performanceViewEnabled
67-
? filterData[ModelCatalogNumberFilterKey.MAX_RPS]
68-
: undefined;
65+
// Always apply performance filters to get accurate benchmark counts, regardless of toggle state
66+
const targetRPS = filterData[ModelCatalogNumberFilterKey.MAX_RPS];
6967
// Get full filter key for display purposes
70-
const latencyFieldName = performanceViewEnabled
71-
? getActiveLatencyFieldName(filterData)
72-
: undefined;
68+
const latencyFieldName = getActiveLatencyFieldName(filterData);
7369
// Use short property key (e.g., 'ttft_p90') for the catalog API, not the full filter key
7470
const latencyProperty = latencyFieldName
7571
? parseLatencyFilterKey(latencyFieldName).propertyKey
7672
: undefined;
7773

7874
// Fetch performance artifacts from the new endpoint with server-side filtering
79-
// When toggle is OFF, don't pass filterData so no perf filters are applied
75+
// Always pass filterData so perf filters are applied - this ensures accurate benchmark counts
76+
// The toggle only controls display, not the artifact fetch filters
8077
const [performanceArtifactsList, performanceArtifactsLoaded, performanceArtifactsError] =
8178
useCatalogPerformanceArtifacts(
8279
source?.id || '',
@@ -94,8 +91,8 @@ const ModelCatalogCardBody: React.FC<ModelCatalogCardBodyProps> = ({
9491
sortOrder: SortOrder.ASC,
9592
}),
9693
},
97-
performanceViewEnabled ? filterData : undefined,
98-
performanceViewEnabled ? filterOptions : undefined,
94+
filterData,
95+
filterOptions,
9996
isValidated, // Only fetch if validated
10097
);
10198

0 commit comments

Comments
 (0)