-
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.
[Enterprise Search] Bind detach ml inference pipeline to the ML infer…
…ence pipeline card (#144098) * Bind detach ml inference pipeline to the ML inference pipeline card
- Loading branch information
Showing
6 changed files
with
176 additions
and
10 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
41 changes: 41 additions & 0 deletions
41
...applications/enterprise_search_content/api/pipelines/detach_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,41 @@ | ||
/* | ||
* 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 { | ||
detachMlInferencePipeline, | ||
DetachMlInferencePipelineResponse, | ||
} from './detach_ml_inference_pipeline'; | ||
|
||
describe('DetachMlInferencePipelineApiLogic', () => { | ||
const { http } = mockHttpValues; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('detachMlInferencePipeline', () => { | ||
it('calls detach ml inference api', async () => { | ||
const response: Promise<DetachMlInferencePipelineResponse> = Promise.resolve({ | ||
updated: 'parent-pipeline-name', | ||
}); | ||
http.delete.mockReturnValue(response); | ||
const result = await detachMlInferencePipeline({ | ||
indexName: 'mock-index-name', | ||
pipelineName: 'mock-pipeline-name', | ||
}); | ||
|
||
expect(http.delete).toHaveBeenCalledWith( | ||
'/internal/enterprise_search/indices/mock-index-name/ml_inference/pipeline_processors/mock-pipeline-name/detach' | ||
); | ||
|
||
expect(result).toEqual({ | ||
updated: 'parent-pipeline-name', | ||
}); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
...blic/applications/enterprise_search_content/api/pipelines/detach_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,30 @@ | ||
/* | ||
* 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 { DeleteMlInferencePipelineResponse } from '../../../../../common/types/pipelines'; | ||
|
||
import { createApiLogic } from '../../../shared/api_logic/create_api_logic'; | ||
import { HttpLogic } from '../../../shared/http'; | ||
|
||
export interface DetachMlInferencePipelineApiLogicArgs { | ||
indexName: string; | ||
pipelineName: string; | ||
} | ||
|
||
export type DetachMlInferencePipelineResponse = DeleteMlInferencePipelineResponse; | ||
|
||
export const detachMlInferencePipeline = async ( | ||
args: DetachMlInferencePipelineApiLogicArgs | ||
): Promise<DetachMlInferencePipelineResponse> => { | ||
const route = `/internal/enterprise_search/indices/${args.indexName}/ml_inference/pipeline_processors/${args.pipelineName}/detach`; | ||
return await HttpLogic.values.http.delete<DetachMlInferencePipelineResponse>(route); | ||
}; | ||
|
||
export const DetachMlInferencePipelineApiLogic = createApiLogic( | ||
['detach_ml_inference_pipeline_api_logic'], | ||
detachMlInferencePipeline | ||
); |
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
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
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