From acd48cccae7aa86fe2866d842ff20d0ed4f51377 Mon Sep 17 00:00:00 2001 From: Samiul Monir <150824886+Samiul-TheSoccerFan@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:04:24 -0500 Subject: [PATCH] [Search][Index Management] Removing Model deployment from Kibana (#198409) ## Summary Clicking on the `Try Again` button tries to redeploy and receives an error. We tried to disable the `Try Again` button if there are no errors in deployment stage. ### Before https://github.com/user-attachments/assets/b1c7b7ce-afba-42ba-a958-d9ad7cbc8777 ### After https://github.com/user-attachments/assets/15ca3a78-a1fc-4079-8ab6-f4b54e7ed333 --------- Co-authored-by: Elastic Machine (cherry picked from commit bc313f4b48680624a0f778eb02eb10158f604a15) --- .../trained_models_deployment_modal.tsx | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/trained_models_deployment_modal.tsx b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/trained_models_deployment_modal.tsx index b2e9a1339c3fb..b3dc5244165fb 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/trained_models_deployment_modal.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/index_list/details_page/trained_models_deployment_modal.tsx @@ -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'; @@ -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(false); const closeModal = () => setIsModalVisible(false); const [mlManagementPageUrl, setMlManagementPageUrl] = useState(''); const [allowForceSaveMappings, setAllowForceSaveMappings] = useState(false); - const { showErrorToasts, showSuccessfullyDeployedToast } = useMLModelNotificationToasts(); useEffect(() => { const mlLocator = url?.locators.get(ML_APP_LOCATOR); @@ -86,25 +80,6 @@ export function TrainedModelsDeploymentModal({ const [pendingDeployments, setPendingDeployments] = useState([]); - 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] @@ -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 : ''; @@ -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(