Skip to content

Commit

Permalink
feat: exclude remote model for admin UI (#225) (#228)
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
(cherry picked from commit ba01d34)

Co-authored-by: Lin Wang <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and wanglam committed Jul 4, 2023
1 parent cc7f21e commit 9b0ea89
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions public/apis/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Model {
size: number;
states?: MODEL_STATE[];
nameOrId?: string;
exclude?: 'REMOTE_MODEL';
}) {
return InnerHttpProvider.getHttp().get<ModelSearchResponse>(MODEL_API_ENDPOINT, {
query,
Expand Down
1 change: 1 addition & 0 deletions public/components/monitoring/use_monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const fetchDeployedModels = async (params: Params) => {
? [MODEL_STATE.loadFailed, MODEL_STATE.loaded, MODEL_STATE.partiallyLoaded]
: states,
sort: [`${params.sort.field}-${params.sort.direction}`],
exclude: 'REMOTE_MODEL',
});
const totalPages = Math.ceil(result.total_models / params.pageSize);
return {
Expand Down
4 changes: 3 additions & 1 deletion server/routes/model_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ export const modelRouter = (router: IRouter) => {
),
states: schema.maybe(schema.oneOf([schema.arrayOf(modelStateSchema), modelStateSchema])),
nameOrId: schema.maybe(schema.string()),
exclude: schema.maybe(schema.literal('REMOTE_MODEL')),
}),
},
},
async (context, request) => {
const { from, size, sort, states, nameOrId } = request.query;
const { from, size, sort, states, nameOrId, exclude } = request.query;
try {
const payload = await ModelService.search({
client: context.core.opensearch.client,
Expand All @@ -55,6 +56,7 @@ export const modelRouter = (router: IRouter) => {
sort: typeof sort === 'string' ? [sort] : sort,
states: typeof states === 'string' ? [states] : states,
nameOrId,
exclude,
});
return opensearchDashboardsResponseFactory.ok({ body: payload });
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions server/services/model_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class ModelService {
sort?: ModelSearchSort[];
states?: MODEL_STATE[];
nameOrId?: string;
exclude?: 'REMOTE_MODEL';
}) {
const {
body: { hits },
Expand Down
21 changes: 17 additions & 4 deletions server/services/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { generateTermQuery } from './query';
export const generateModelSearchQuery = ({
states,
nameOrId,
exclude,
}: {
states?: MODEL_STATE[];
nameOrId?: string;
exclude?: 'REMOTE_MODEL';
}) => ({
bool: {
must: [
Expand All @@ -33,10 +35,21 @@ export const generateModelSearchQuery = ({
]
: []),
],
must_not: {
exists: {
field: 'chunk_number',
must_not: [
{
exists: {
field: 'chunk_number',
},
},
},
...(exclude === 'REMOTE_MODEL'
? [
{
term: {
algorithm: 'REMOTE',
},
},
]
: []),
],
},
});

0 comments on commit 9b0ea89

Please sign in to comment.