Skip to content

Commit

Permalink
[ELSER Model Deployment] Remove useless check (elastic#168781)
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret authored Oct 13, 2023
1 parent 63072dd commit 2cbb98b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
* 2.0.
*/

import { ELASTIC_MODEL_DEFINITIONS } from '@kbn/ml-trained-models-utils';

import {
ElasticsearchResponseError,
isNotFoundException,
isResourceNotFoundException,
} from '../../utils/identify_exceptions';

export const acceptableModelNames = Object.keys(ELASTIC_MODEL_DEFINITIONS);

export function isNotFoundExceptionError(error: unknown): boolean {
return (
isResourceNotFoundException(error as ElasticsearchResponseError) ||
Expand All @@ -23,20 +19,3 @@ export function isNotFoundExceptionError(error: unknown): boolean {
error?.statusCode === 404
);
}

export function throwIfNotAcceptableModelName(modelName: string) {
if (!acceptableModelNames.includes(modelName)) {
const notFoundError: ElasticsearchResponseError = {
meta: {
body: {
error: {
type: 'resource_not_found_exception',
},
},
statusCode: 404,
},
name: 'ResponseError',
};
throw notFoundError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server';
import { MlModelDeploymentStatus, MlModelDeploymentState } from '../../../common/types/ml';

import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status';
import {
isNotFoundExceptionError,
throwIfNotAcceptableModelName,
} from './ml_model_deployment_common';
import { isNotFoundExceptionError } from './ml_model_deployment_common';

export const startMlModelDeployment = async (
modelName: string,
Expand All @@ -25,10 +22,6 @@ export const startMlModelDeployment = async (
throw new Error('Machine Learning is not enabled');
}

// before anything else, check our model name
// to ensure we only allow those names we want
throwIfNotAcceptableModelName(modelName);

try {
// try and get the deployment status of the model first
// and see if it's already deployed or deploying...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server';
import { MlModelDeploymentState, MlModelDeploymentStatus } from '../../../common/types/ml';

import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status';
import {
isNotFoundExceptionError,
throwIfNotAcceptableModelName,
} from './ml_model_deployment_common';
import { isNotFoundExceptionError } from './ml_model_deployment_common';

export const startMlModelDownload = async (
modelName: string,
Expand All @@ -24,10 +21,6 @@ export const startMlModelDownload = async (
throw new Error('Machine Learning is not enabled');
}

// before anything else, check our model name
// to ensure we only allow those names we want
throwIfNotAcceptableModelName(modelName);

try {
// try and get the deployment status of the model first
// and see if it's already deployed or deploying...
Expand Down

0 comments on commit 2cbb98b

Please sign in to comment.