-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attach existing ml inference pipeline
Added the ability to choose an existing ml inference pipeline and attach it to the index. This will re-use the existing pipeline instead of creating a new one.
- Loading branch information
1 parent
e0b5bdb
commit f8e18e3
Showing
16 changed files
with
658 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...applications/enterprise_search_content/api/pipelines/attach_ml_inference_pipeline.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { mockHttpValues } from '../../../__mocks__/kea_logic'; | ||
|
||
import { | ||
attachMlInferencePipeline, | ||
AttachMlInferencePipelineApiLogicArgs, | ||
AttachMlInferencePipelineResponse, | ||
} from './attach_ml_inference_pipeline'; | ||
|
||
describe('AttachMlInferencePipelineApiLogic', () => { | ||
const { http } = mockHttpValues; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
describe('createMlInferencePipeline', () => { | ||
it('calls the api', async () => { | ||
const response: Promise<AttachMlInferencePipelineResponse> = Promise.resolve({ | ||
addedToParentPipeline: true, | ||
created: false, | ||
id: 'unit-test', | ||
}); | ||
http.post.mockReturnValue(response); | ||
|
||
const args: AttachMlInferencePipelineApiLogicArgs = { | ||
indexName: 'unit-test-index', | ||
pipelineName: 'unit-test', | ||
}; | ||
const result = await attachMlInferencePipeline(args); | ||
expect(http.post).toHaveBeenCalledWith( | ||
'/internal/enterprise_search/indices/unit-test-index/ml_inference/pipeline_processors/attach', | ||
{ | ||
body: '{"pipeline_name":"unit-test"}', | ||
} | ||
); | ||
expect(result).toEqual({ | ||
addedToParentPipeline: true, | ||
created: false, | ||
id: args.pipelineName, | ||
}); | ||
}); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
...blic/applications/enterprise_search_content/api/pipelines/attach_ml_inference_pipeline.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AttachMlInferencePipelineResponse } from '../../../../../common/types/pipelines'; | ||
|
||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export interface AttachMlInferencePipelineApiLogicArgs { | ||
indexName: string; | ||
pipelineName: string; | ||
} | ||
|
||
export type { AttachMlInferencePipelineResponse }; | ||
|
||
export const attachMlInferencePipeline = async ( | ||
args: AttachMlInferencePipelineApiLogicArgs | ||
): Promise<AttachMlInferencePipelineResponse> => { | ||
const route = `/internal/enterprise_search/indices/${args.indexName}/ml_inference/pipeline_processors/attach`; | ||
const params = { | ||
pipeline_name: args.pipelineName, | ||
}; | ||
|
||
return await HttpLogic.values.http.post<AttachMlInferencePipelineResponse>(route, { | ||
body: JSON.stringify(params), | ||
}); | ||
}; | ||
|
||
export const AttachMlInferencePipelineApiLogic = createApiLogic( | ||
['attach_ml_inference_pipeline_api_logic'], | ||
attachMlInferencePipeline | ||
); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...blic/applications/enterprise_search_content/api/pipelines/fetch_ml_inference_pipelines.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { MlInferencePipeline } from '../../../../../common/types/pipelines'; | ||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export type FetchMlInferencePipelinesArgs = undefined; | ||
export type FetchMlInferencePipelinesResponse = Record<string, MlInferencePipeline | undefined>; | ||
|
||
export const fetchMlInferencePipelines = async () => { | ||
const route = '/internal/enterprise_search/pipelines/ml_inference'; | ||
|
||
return await HttpLogic.values.http.get<FetchMlInferencePipelinesResponse>(route); | ||
}; | ||
|
||
export const FetchMlInferencePipelinesApiLogic = createApiLogic( | ||
['fetch_ml_inference_pipelines_api_logic'], | ||
fetchMlInferencePipelines | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.