Skip to content

Commit

Permalink
Revert "support force stop"
Browse files Browse the repository at this point in the history
This reverts commit 1b1a3b2
  • Loading branch information
darnautov committed Nov 15, 2021
1 parent 3c001d9 commit 76caf13
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,10 @@ export function trainedModelsApiProvider(httpService: HttpService) {
});
},

stopModelAllocation(modelId: string, options: { force: boolean } = { force: false }) {
const force = options?.force;

stopModelAllocation(modelId: string) {
return httpService.http<{ acknowledge: boolean }>({
path: `${apiBasePath}/trained_models/${modelId}/deployment/_stop`,
method: 'POST',
query: { force },
});
},
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import { useFieldFormatter } from '../../contexts/kibana/use_field_formatter';
import { FIELD_FORMAT_IDS } from '../../../../../../../src/plugins/field_formats/common';
import { useRefresh } from '../../routing/use_refresh';
import { DEPLOYMENT_STATE } from '../../../../common/constants/trained_models';
import { getUserConfirmationProvider } from './force_stop_dialog';

type Stats = Omit<TrainedModelStat, 'model_id'>;

Expand Down Expand Up @@ -81,7 +80,6 @@ export const ModelsList: FC = () => {
const {
services: {
application: { navigateToUrl, capabilities },
overlays,
},
} = useMlKibana();
const urlLocator = useMlLocator()!;
Expand Down Expand Up @@ -112,8 +110,6 @@ export const ModelsList: FC = () => {
{}
);

const getUserConfirmation = useMemo(() => getUserConfirmationProvider(overlays), []);

const navigateToPath = useNavigateToPath();

const isBuiltInModel = useCallback(
Expand Down Expand Up @@ -422,21 +418,13 @@ export const ModelsList: FC = () => {
available: (item) => item.model_type === 'pytorch',
enabled: (item) =>
!isLoading &&
!isPopulatedObject(item.pipelines) &&
isPopulatedObject(item.stats?.deployment_stats) &&
item.stats?.deployment_stats?.state !== DEPLOYMENT_STATE.STOPPING,
onClick: async (item) => {
const requireForceStop = isPopulatedObject(item.pipelines);

if (requireForceStop) {
const hasUserApproved = await getUserConfirmation(item);
if (!hasUserApproved) return;
}

try {
setIsLoading(true);
await trainedModelsApiService.stopModelAllocation(item.model_id, {
force: requireForceStop,
});
await trainedModelsApiService.stopModelAllocation(item.model_id);
displaySuccessToast(
i18n.translate('xpack.ml.trainedModels.modelsList.stopSuccess', {
defaultMessage: 'Deployment for "{modelId}" has been stopped successfully.',
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/ml/server/routes/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { modelsProvider } from '../models/data_frame_analytics';
import { TrainedModelConfigResponse } from '../../common/types/trained_models';
import { memoryOverviewServiceProvider } from '../models/memory_overview';
import { mlLog } from '../lib/log';
import { forceQuerySchema } from './schemas/anomaly_detectors_schema';

export function trainedModelsRoutes({ router, routeGuard }: RouteInitialization) {
/**
Expand Down Expand Up @@ -263,7 +262,6 @@ export function trainedModelsRoutes({ router, routeGuard }: RouteInitialization)
path: '/api/ml/trained_models/{modelId}/deployment/_stop',
validate: {
params: modelIdSchema,
query: forceQuerySchema,
},
options: {
tags: ['access:ml:canGetDataFrameAnalytics'],
Expand All @@ -274,7 +272,6 @@ export function trainedModelsRoutes({ router, routeGuard }: RouteInitialization)
const { modelId } = request.params;
const { body } = await mlClient.stopTrainedModelDeployment({
model_id: modelId,
force: request.query.force ?? false,
});
return response.ok({
body,
Expand Down

0 comments on commit 76caf13

Please sign in to comment.