Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] feat: exclude remote model for admin UI #228

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
},
},
]
: []),
],
},
});
Loading