Skip to content

Commit 4ad3028

Browse files
committed
Update @odh-dashboard/model-registry: Fix the cold start filtering from being passed when the performance toggle is off (#2853)
Upstream commit: acdf0135544891be7e245017356b6731e5e01e56
1 parent 2df5f80 commit 4ad3028

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

packages/model-registry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"branch": "main",
2424
"src": "clients/ui",
2525
"target": "upstream",
26-
"commit": "5848ed75b70f288eebd6e9509e90b22ea9be34e2"
26+
"commit": "acdf0135544891be7e245017356b6731e5e01e56"
2727
},
2828
"module-federation": {
2929
"name": "modelRegistry",

packages/model-registry/upstream/frontend/src/app/api/modelCatalog/service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const getCatalogModelsBySource =
3838
): Promise<CatalogModelList> => {
3939
const computedFilterQuery =
4040
filterQuery ??
41-
(filterData && filterOptions ? filtersToFilterQuery(filterData, filterOptions) : '');
41+
(filterData && filterOptions
42+
? filtersToFilterQuery(filterData, filterOptions, 'models', !!performanceParams)
43+
: '');
4244

4345
const allParams = {
4446
source: sourceId,

packages/model-registry/upstream/frontend/src/app/pages/modelCatalog/utils/__tests__/modelCatalogUtils.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,44 @@ describe('filtersToFilterQuery', () => {
489489
expect(query).toContain('modelcar_image_size.double_value <= 10');
490490
});
491491
});
492+
493+
describe('includeColdStartClause parameter', () => {
494+
it('does not append cold-start OR clause when includeColdStartClause is false', () => {
495+
const query = filtersToFilterQuery(
496+
mockFormData({ tasks: [ModelCatalogTask.TEXT_TO_TEXT] }),
497+
mockFilterOptions,
498+
'models',
499+
false,
500+
);
501+
expect(query).toBe("tasks='text-to-text'");
502+
expect(query).not.toContain('performance_sub_type');
503+
expect(query).not.toContain('cold-start');
504+
});
505+
506+
it('appends cold-start OR clause when includeColdStartClause is true (default)', () => {
507+
const query = filtersToFilterQuery(
508+
mockFormData({ tasks: [ModelCatalogTask.TEXT_TO_TEXT] }),
509+
mockFilterOptions,
510+
'models',
511+
true,
512+
);
513+
expect(query).toContain("OR artifacts.performance_sub_type.string_value='cold-start'");
514+
});
515+
516+
it('does not append cold-start OR clause with multiple basic filters when performance is off', () => {
517+
const query = filtersToFilterQuery(
518+
mockFormData({
519+
tasks: [ModelCatalogTask.TEXT_TO_TEXT],
520+
provider: [ModelCatalogProvider.GOOGLE],
521+
}),
522+
mockFilterOptions,
523+
'models',
524+
false,
525+
);
526+
expect(query).toBe("tasks='text-to-text' AND provider='Google'");
527+
expect(query).not.toContain('performance_sub_type');
528+
});
529+
});
492530
});
493531

494532
describe('catalog source filtering utilities', () => {

packages/model-registry/upstream/frontend/src/app/pages/modelCatalog/utils/modelCatalogUtils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,16 @@ const serializeFilterEntry = (
456456
* @param target - The target endpoint:
457457
* - 'models': Include all filters (except RPS), use filter keys directly
458458
* - 'artifacts': Only include artifact-prefixed filters, strip the prefix in output
459+
* @param includeColdStartClause - Whether to append the cold-start OR clause.
460+
* Should be true only when performance view is enabled.
459461
*
460462
* Note: RPS is NOT included in filterQuery for either target - it's passed as targetRPS param.
461463
*/
462464
export const filtersToFilterQuery = (
463465
filterData: ModelCatalogFilterStates,
464466
options: CatalogFilterOptionsList,
465467
target: FilterQueryTarget = 'models',
468+
includeColdStartClause = true,
466469
): string => {
467470
const serializedFilters: string[] = Object.entries(filterData)
468471
.filter(([filterId]) => shouldIncludeFilter(filterId, target))
@@ -474,6 +477,11 @@ export const filtersToFilterQuery = (
474477
}
475478

476479
const baseQuery = nonEmptyFilters.join(' AND ');
480+
481+
if (!includeColdStartClause) {
482+
return baseQuery;
483+
}
484+
477485
const coldStartClause = buildColdStartOrClause(filterData, options, target);
478486
return `${baseQuery} OR ${coldStartClause}`;
479487
};

0 commit comments

Comments
 (0)