Skip to content

Commit

Permalink
[Enterprise Search] fix(index inference pipelines): fetch models on e…
Browse files Browse the repository at this point in the history
…lser deploy (#157318)

## Summary

Updated the inference pipeline flyout logic to refetch ml models when
the user deploys the ELSER text expansion model. This will allow them to
select the model if they deploy it from the flyout.


https://github.com/elastic/kibana/assets/1972968/25916c61-cdad-4213-8034-265aaac1f945

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
TattdCodeMonkey and kibanamachine authored May 11, 2023
1 parent dcf1c23 commit efac422
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { TrainedModelState } from '../../../../../../../common/types/pipelines';
import { GetDocumentsApiLogic } from '../../../../api/documents/get_document_logic';
import { MappingsApiLogic } from '../../../../api/mappings/mappings_logic';
import { MLModelsApiLogic } from '../../../../api/ml_models/ml_models_logic';
import { StartTextExpansionModelApiLogic } from '../../../../api/ml_models/text_expansion/start_text_expansion_model_api_logic';
import { AttachMlInferencePipelineApiLogic } from '../../../../api/pipelines/attach_ml_inference_pipeline';
import { CreateMlInferencePipelineApiLogic } from '../../../../api/pipelines/create_ml_inference_pipeline';
import { FetchMlInferencePipelineProcessorsApiLogic } from '../../../../api/pipelines/fetch_ml_inference_pipeline_processors';
Expand Down Expand Up @@ -85,6 +86,7 @@ describe('MlInferenceLogic', () => {
FetchMlInferencePipelinesApiLogic
);
const { mount: mountGetDocumentsApiLogic } = new LogicMounter(GetDocumentsApiLogic);
const { mount: mountStartTextExpansionModel } = new LogicMounter(StartTextExpansionModelApiLogic);

beforeEach(() => {
jest.clearAllMocks();
Expand All @@ -97,6 +99,7 @@ describe('MlInferenceLogic', () => {
mountCreateMlInferencePipelineApiLogic();
mountAttachMlInferencePipelineApiLogic();
mountGetDocumentsApiLogic();
mountStartTextExpansionModel();
mount();
});

Expand Down Expand Up @@ -628,5 +631,16 @@ describe('MlInferenceLogic', () => {
});
});
});
describe('startTextExpansionModelSuccess', () => {
it('fetches ml models', () => {
jest.spyOn(MLInferenceLogic.actions, 'makeMLModelsRequest');
StartTextExpansionModelApiLogic.actions.apiSuccess({
deploymentState: 'started',
modelId: 'foo',
});

expect(MLInferenceLogic.actions.makeMLModelsRequest).toHaveBeenCalledWith(undefined);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
TrainedModelsApiLogicActions,
TrainedModelsApiLogic,
} from '../../../../api/ml_models/ml_trained_models_logic';
import {
StartTextExpansionModelApiLogic,
StartTextExpansionModelApiLogicActions,
} from '../../../../api/ml_models/text_expansion/start_text_expansion_model_api_logic';
import {
AttachMlInferencePipelineApiLogic,
AttachMlInferencePipelineApiLogicArgs,
Expand Down Expand Up @@ -156,6 +160,7 @@ interface MLInferenceProcessorsActions {
setInferencePipelineConfiguration: (configuration: InferencePipelineConfiguration) => {
configuration: InferencePipelineConfiguration;
};
startTextExpansionModelSuccess: StartTextExpansionModelApiLogicActions['apiSuccess'];
}

export interface AddInferencePipelineModal {
Expand Down Expand Up @@ -230,6 +235,8 @@ export const MLInferenceLogic = kea<
],
PipelinesLogic,
['closeAddMlInferencePipelineModal as closeAddMlInferencePipelineModal'],
StartTextExpansionModelApiLogic,
['apiSuccess as startTextExpansionModelSuccess'],
],
values: [
CachedFetchIndexApiLogic,
Expand Down Expand Up @@ -316,6 +323,10 @@ export const MLInferenceLogic = kea<
});
}
},
startTextExpansionModelSuccess: () => {
// Refresh ML models list when the text expansion model is started
actions.makeMLModelsRequest(undefined);
},
}),
path: ['enterprise_search', 'content', 'pipelines_add_ml_inference_pipeline'],
reducers: {
Expand Down

0 comments on commit efac422

Please sign in to comment.