Skip to content

Commit

Permalink
[8.16] [Search][Index Management] Removing Model deployment from Kiba…
Browse files Browse the repository at this point in the history
…na (#198409) (#199201)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Search][Index Management] Removing Model deployment from Kibana
(#198409)](#198409)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Samiul
Monir","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-06T18:04:24Z","message":"[Search][Index
Management] Removing Model deployment from Kibana (#198409)\n\n##
Summary\r\n\r\nClicking on the `Try Again` button tries to redeploy and
receives an\r\nerror. We tried to disable the `Try Again` button if
there are no errors\r\nin deployment stage.\r\n\r\n\r\n###
Before\r\n\r\n\r\nhttps://github.com/user-attachments/assets/b1c7b7ce-afba-42ba-a958-d9ad7cbc8777\r\n\r\n###
After\r\n\r\n\r\nhttps://github.com/user-attachments/assets/15ca3a78-a1fc-4079-8ab6-f4b54e7ed333\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"bc313f4b48680624a0f778eb02eb10158f604a15","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","v8.16.0","backport:version","v8.17.0"],"title":"[Search][Index
Management] Removing Model deployment from
Kibana","number":198409,"url":"https://github.com/elastic/kibana/pull/198409","mergeCommit":{"message":"[Search][Index
Management] Removing Model deployment from Kibana (#198409)\n\n##
Summary\r\n\r\nClicking on the `Try Again` button tries to redeploy and
receives an\r\nerror. We tried to disable the `Try Again` button if
there are no errors\r\nin deployment stage.\r\n\r\n\r\n###
Before\r\n\r\n\r\nhttps://github.com/user-attachments/assets/b1c7b7ce-afba-42ba-a958-d9ad7cbc8777\r\n\r\n###
After\r\n\r\n\r\nhttps://github.com/user-attachments/assets/15ca3a78-a1fc-4079-8ab6-f4b54e7ed333\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"bc313f4b48680624a0f778eb02eb10158f604a15"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198409","number":198409,"mergeCommit":{"message":"[Search][Index
Management] Removing Model deployment from Kibana (#198409)\n\n##
Summary\r\n\r\nClicking on the `Try Again` button tries to redeploy and
receives an\r\nerror. We tried to disable the `Try Again` button if
there are no errors\r\nin deployment stage.\r\n\r\n\r\n###
Before\r\n\r\n\r\nhttps://github.com/user-attachments/assets/b1c7b7ce-afba-42ba-a958-d9ad7cbc8777\r\n\r\n###
After\r\n\r\n\r\nhttps://github.com/user-attachments/assets/15ca3a78-a1fc-4079-8ab6-f4b54e7ed333\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"bc313f4b48680624a0f778eb02eb10158f604a15"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Samiul Monir <[email protected]>
  • Loading branch information
kibanamachine and Samiul-TheSoccerFan authored Nov 6, 2024
1 parent 720f260 commit 2095008
Showing 1 changed file with 1 addition and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import React from 'react';
import { EuiLink } from '@elastic/eui';
import { useEffect, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { ModelIdMapEntry } from '../../../../components/mappings_editor/components/document_fields/fields';
import { isSemanticTextField } from '../../../../components/mappings_editor/lib/utils';
import { deNormalize } from '../../../../components/mappings_editor/lib';
import { useMLModelNotificationToasts } from '../../../../../hooks/use_ml_model_status_toasts';
import { useMappingsState } from '../../../../components/mappings_editor/mappings_state_context';
import { useAppContext } from '../../../../app_context';

Expand All @@ -55,15 +53,11 @@ export function TrainedModelsDeploymentModal({
}: TrainedModelsDeploymentModalProps) {
const modalTitleId = useGeneratedHtmlId();
const { fields, inferenceToModelIdMap } = useMappingsState();
const {
plugins: { ml },
url,
} = useAppContext();
const { url } = useAppContext();
const [isModalVisible, setIsModalVisible] = useState<boolean>(false);
const closeModal = () => setIsModalVisible(false);
const [mlManagementPageUrl, setMlManagementPageUrl] = useState<string>('');
const [allowForceSaveMappings, setAllowForceSaveMappings] = useState<boolean>(false);
const { showErrorToasts, showSuccessfullyDeployedToast } = useMLModelNotificationToasts();

useEffect(() => {
const mlLocator = url?.locators.get(ML_APP_LOCATOR);
Expand All @@ -86,25 +80,6 @@ export function TrainedModelsDeploymentModal({

const [pendingDeployments, setPendingDeployments] = useState<string[]>([]);

const startModelAllocation = async (entry: ModelIdMapEntry & { inferenceId: string }) => {
try {
await ml?.mlApi?.trainedModels.startModelAllocation(entry.trainedModelId, {
number_of_allocations: 1,
threads_per_allocation: 1,
priority: 'normal',
deployment_id: entry.inferenceId,
});
showSuccessfullyDeployedToast(entry.trainedModelId);
} catch (error) {
setErrorsInTrainedModelDeployment((previousState) => ({
...previousState,
[entry.inferenceId]: error.message,
}));
showErrorToasts(error);
setIsModalVisible(true);
}
};

useEffect(() => {
const models = inferenceIdsInPendingList.map((inferenceId) =>
inferenceToModelIdMap?.[inferenceId]
Expand All @@ -114,18 +89,6 @@ export function TrainedModelsDeploymentModal({
}
: undefined
); // filter out third-party models
for (const model of models) {
if (
model?.trainedModelId &&
model.isDeployable &&
!model.isDownloading &&
!model.isDeployed
) {
// Sometimes the model gets stuck in a ready to deploy state, so we need to trigger deployment manually
// This is currently the only way to surface a specific error message to the user
startModelAllocation(model);
}
}
const allPendingDeployments = models
.map((model) => {
return model?.trainedModelId && !model?.isDeployed ? model?.inferenceId : '';
Expand All @@ -135,7 +98,6 @@ export function TrainedModelsDeploymentModal({
(deployment, index) => allPendingDeployments.indexOf(deployment) === index
);
setPendingDeployments(uniqueDeployments);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [inferenceIdsInPendingList, inferenceToModelIdMap]);

const erroredDeployments = pendingDeployments.filter(
Expand Down

0 comments on commit 2095008

Please sign in to comment.