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

Onboard ML inference processors for search request / search response (form) #180

Merged
merged 5 commits into from
Jun 15, 2024
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
6 changes: 6 additions & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,9 @@ export const FETCH_ALL_QUERY_BODY = {
size: 1000,
};
export const INDEX_NOT_FOUND_EXCEPTION = 'index_not_found_exception';

export enum PROCESSOR_CONTEXT {
INGEST = 'ingest',
SEARCH_REQUEST = 'search_request',
SEARCH_RESPONSE = 'search_response',
}
8 changes: 4 additions & 4 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface IProcessorConfig extends IConfig {
type: PROCESSOR_TYPE;
}

export type EnrichConfig = {
export type ProcessorsConfig = {
processors: IProcessorConfig[];
};

Expand All @@ -51,14 +51,14 @@ export type IndexConfig = {

export type IngestConfig = {
source: IConfig;
enrich: EnrichConfig;
enrich: ProcessorsConfig;
index: IndexConfig;
};

export type SearchConfig = {
request: IConfig;
enrichRequest: IConfig;
enrichResponse: IConfig;
enrichRequest: ProcessorsConfig;
enrichResponse: ProcessorsConfig;
};

export type WorkflowConfig = {
Expand Down
2 changes: 2 additions & 0 deletions public/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*/

export * from './ingest_processors';
export * from './search_request_processors';
export * from './search_response_processors';
6 changes: 6 additions & 0 deletions public/configs/search_request_processors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './ml_search_request_processor';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { generateId } from '../../utils';
import { MLProcessor } from '../ml_processor';

/**
* The ML processor in the context of search request
*/
export class MLSearchRequestProcessor extends MLProcessor {
constructor() {
super();
this.id = generateId('ml_processor_search_request');
}
}
6 changes: 6 additions & 0 deletions public/configs/search_response_processors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './ml_search_response_processor';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { generateId } from '../../utils';
import { MLProcessor } from '../ml_processor';

/**
* The ML processor in the context of search response
*/
export class MLSearchResponseProcessor extends MLProcessor {
constructor() {
super();
this.id = generateId('ml_processor_search_response');
}
}
1 change: 1 addition & 0 deletions public/general_components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

export { MultiSelectFilter } from './multi_select_filter';
export { DeleteWorkflowModal } from './delete_workflow_modal';
export { ProcessorsTitle } from './processors_title';
33 changes: 33 additions & 0 deletions public/general_components/processors_title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { EuiFlexItem, EuiTitle } from '@elastic/eui';

interface ProcessorsTitleProps {
title: string;
processorCount: number;
}

/**
* General component for formatting processor titles
*/
export function ProcessorsTitle(props: ProcessorsTitleProps) {
return (
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<div>
<h2
style={{ display: 'inline-block' }}
>{`${props.title} (${props.processorCount}) -`}</h2>
&nbsp;
<h2 style={{ display: 'inline-block', fontStyle: 'italic' }}>
optional
</h2>
</div>
</EuiTitle>
</EuiFlexItem>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
*/

import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
import { ProcessorsList } from './processors_list';
import { WorkflowConfig } from '../../../../../common';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { ProcessorsList } from '../processors_list';
import { PROCESSOR_CONTEXT, WorkflowConfig } from '../../../../../common';
import { ProcessorsTitle } from '../../../../general_components';

interface EnrichDataProps {
onFormChange: () => void;
Expand All @@ -20,16 +21,16 @@ interface EnrichDataProps {
export function EnrichData(props: EnrichDataProps) {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h4>Enrich data</h4>
</EuiTitle>
</EuiFlexItem>
<ProcessorsTitle
title="Enrich data"
processorCount={props.uiConfig.ingest.enrich.processors?.length || 0}
/>
<EuiFlexItem>
<ProcessorsList
onFormChange={props.onFormChange}
uiConfig={props.uiConfig}
setUiConfig={props.setUiConfig}
context={PROCESSOR_CONTEXT.INGEST}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function IngestData(props: IngestDataProps) {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h4>Ingest data</h4>
<EuiTitle size="s">
<h2>Ingest data</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export function SourceData(props: SourceDataProps) {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h4>Source data</h4>
<EuiTitle size="s">
<h2>Source data</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Loading
Loading