From c14e3444ee12f54f5112322b01ce8818db67b013 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Thu, 1 Oct 2020 16:17:35 -0600 Subject: [PATCH 1/2] allow user to create job when mml is lower than estimate --- .../components/advanced_step/advanced_step_form.tsx | 9 ++++++--- .../hooks/use_create_analytics_form/reducer.ts | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx index 7409e414af2b6..1aad5dfd9cfb9 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/advanced_step/advanced_step_form.tsx @@ -78,7 +78,10 @@ export const AdvancedStepForm: FC = ({ const isRegOrClassJob = jobType === ANALYSIS_CONFIG_TYPE.REGRESSION || jobType === ANALYSIS_CONFIG_TYPE.CLASSIFICATION; - const mmlInvalid = modelMemoryLimitValidationResult !== null; + const mmlInvalid = + modelMemoryLimitValidationResult !== null && + (modelMemoryLimitValidationResult.invalidUnits !== undefined || + modelMemoryLimitValidationResult.required === true); const isStepInvalid = mmlInvalid || @@ -340,7 +343,7 @@ export const AdvancedStepForm: FC = ({ label={i18n.translate('xpack.ml.dataframe.analytics.create.modelMemoryLimitLabel', { defaultMessage: 'Model memory limit', })} - isInvalid={mmlInvalid} + isInvalid={modelMemoryLimitValidationResult !== null} error={mmlErrors} helpText={i18n.translate( 'xpack.ml.dataframe.analytics.create.modelMemoryLimitHelpText', @@ -359,7 +362,7 @@ export const AdvancedStepForm: FC = ({ disabled={isJobCreated} value={modelMemoryLimit || ''} onChange={(e) => setFormState({ modelMemoryLimit: e.target.value })} - isInvalid={mmlInvalid} + isInvalid={modelMemoryLimitValidationResult !== null} data-test-subj="mlAnalyticsCreateJobWizardModelMemoryInput" /> diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts index 59c6f7249408d..59a329b2898c1 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts @@ -72,7 +72,7 @@ export function getModelMemoryLimitErrors(mmlValidationResult: any): string[] | if (errorKey === 'min') { acc.push( i18n.translate('xpack.ml.dataframe.analytics.create.modelMemoryUnitsMinError', { - defaultMessage: 'Model memory limit cannot be lower than {mml}', + defaultMessage: 'Model memory limit is lower than estimated value {mml}', values: { mml: mmlValidationResult.min.minValue, }, @@ -425,12 +425,13 @@ const validateForm = (state: State): State => { dependentVariable === ''; const mmlValidationResult = validateMml(estimatedModelMemoryLimit, modelMemoryLimit); + const mmlInvalid = mmlValidationResult !== null && mmlValidationResult.invalidUnits !== undefined; state.form.modelMemoryLimitValidationResult = mmlValidationResult; state.isValid = !jobTypeEmpty && - !mmlValidationResult && + mmlInvalid && !jobIdEmpty && jobIdValid && !jobIdExists && From 2c7099ada60f44e5d1962b8c6cd79aed0a19e97c Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Fri, 2 Oct 2020 11:31:28 -0600 Subject: [PATCH 2/2] ensure mml validation works as expected --- .../hooks/use_create_analytics_form/reducer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts index 59a329b2898c1..6fb3904e76ecb 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/reducer.ts @@ -425,13 +425,15 @@ const validateForm = (state: State): State => { dependentVariable === ''; const mmlValidationResult = validateMml(estimatedModelMemoryLimit, modelMemoryLimit); - const mmlInvalid = mmlValidationResult !== null && mmlValidationResult.invalidUnits !== undefined; + const mmlInvalid = + mmlValidationResult !== null && + (mmlValidationResult.invalidUnits !== undefined || mmlValidationResult.required === true); state.form.modelMemoryLimitValidationResult = mmlValidationResult; state.isValid = !jobTypeEmpty && - mmlInvalid && + !mmlInvalid && !jobIdEmpty && jobIdValid && !jobIdExists &&