Skip to content

Commit

Permalink
[ML] DF Analytics creation wizard: ensure job creation possible when …
Browse files Browse the repository at this point in the history
…model memory lower than estimate (#79229) (#79670)

* allow user to create job when mml is lower than estimate

* ensure mml validation works as expected
  • Loading branch information
alvarezmelissa87 authored Oct 6, 2020
1 parent ead5a5d commit bcc29ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
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 ||
Expand Down Expand Up @@ -340,7 +343,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
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',
Expand All @@ -359,7 +362,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
disabled={isJobCreated}
value={modelMemoryLimit || ''}
onChange={(e) => setFormState({ modelMemoryLimit: e.target.value })}
isInvalid={mmlInvalid}
isInvalid={modelMemoryLimitValidationResult !== null}
data-test-subj="mlAnalyticsCreateJobWizardModelMemoryInput"
/>
</EuiFormRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -425,12 +425,15 @@ const validateForm = (state: State): State => {
dependentVariable === '';

const mmlValidationResult = validateMml(estimatedModelMemoryLimit, modelMemoryLimit);
const mmlInvalid =
mmlValidationResult !== null &&
(mmlValidationResult.invalidUnits !== undefined || mmlValidationResult.required === true);

state.form.modelMemoryLimitValidationResult = mmlValidationResult;

state.isValid =
!jobTypeEmpty &&
!mmlValidationResult &&
!mmlInvalid &&
!jobIdEmpty &&
jobIdValid &&
!jobIdExists &&
Expand Down

0 comments on commit bcc29ac

Please sign in to comment.