Skip to content

Commit

Permalink
[ML] DF Analytics wizard: ensure user can set mml manually or select …
Browse files Browse the repository at this point in the history
…to use given estimate (#81078)

* add switch for using estimated mml

* persist useEstimatedMml when switching between steps

* update translation name to be consistent
  • Loading branch information
alvarezmelissa87 authored Oct 21, 2020
1 parent 9aa9290 commit 7349897
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
EuiLink,
EuiSelect,
EuiSpacer,
EuiSwitch,
EuiTitle,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -138,7 +139,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;

const { setEstimatedModelMemoryLimit, setFormState } = actions;
const { form, isJobCreated } = state;
const { form, isJobCreated, estimatedModelMemoryLimit } = state;
const {
computeFeatureInfluence,
eta,
Expand All @@ -159,6 +160,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
outlierFraction,
predictionFieldName,
randomizeSeed,
useEstimatedMml,
} = form;

const [numTopClassesOptions, setNumTopClassesOptions] = useState<EuiComboBoxOptionOption[]>([
Expand Down Expand Up @@ -204,7 +206,9 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
if (success) {
if (modelMemoryLimit !== expectedMemory) {
setEstimatedModelMemoryLimit(expectedMemory);
setFormState({ modelMemoryLimit: expectedMemory });
if (useEstimatedMml === true) {
setFormState({ modelMemoryLimit: expectedMemory });
}
}
} else {
// Check which field is invalid
Expand Down Expand Up @@ -481,18 +485,35 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
}
)}
>
<EuiFieldText
placeholder={
jobType !== undefined
? DEFAULT_MODEL_MEMORY_LIMIT[jobType]
: DEFAULT_MODEL_MEMORY_LIMIT.outlier_detection
}
disabled={isJobCreated}
value={modelMemoryLimit || ''}
onChange={(e) => setFormState({ modelMemoryLimit: e.target.value })}
isInvalid={modelMemoryLimitValidationResult !== null}
data-test-subj="mlAnalyticsCreateJobWizardModelMemoryInput"
/>
<>
<EuiFieldText
placeholder={
jobType !== undefined
? DEFAULT_MODEL_MEMORY_LIMIT[jobType]
: DEFAULT_MODEL_MEMORY_LIMIT.outlier_detection
}
disabled={isJobCreated || useEstimatedMml}
value={useEstimatedMml ? estimatedModelMemoryLimit : modelMemoryLimit || ''}
onChange={(e) => setFormState({ modelMemoryLimit: e.target.value })}
isInvalid={modelMemoryLimitValidationResult !== null}
data-test-subj="mlAnalyticsCreateJobWizardModelMemoryInput"
/>
<EuiSpacer size="s" />
<EuiSwitch
disabled={isJobCreated}
name="mlDataFrameAnalyticsUseEstimatedMml"
label={i18n.translate('xpack.ml.dataframe.analytics.create.useEstimatedMmlLabel', {
defaultMessage: 'Use estimated model memory limit',
})}
checked={useEstimatedMml === true}
onChange={() =>
setFormState({
useEstimatedMml: !useEstimatedMml,
})
}
data-test-subj="mlAnalyticsCreateJobWizardUseEstimatedMml"
/>
</>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({
requiredFieldsError,
sourceIndex,
trainingPercent,
useEstimatedMml,
} = form;

const toastNotifications = getToastNotifications();
Expand Down Expand Up @@ -164,7 +165,8 @@ export const ConfigurationStepForm: FC<CreateAnalyticsStepProps> = ({

const debouncedGetExplainData = debounce(async () => {
const jobTypeChanged = previousJobType !== jobType;
const shouldUpdateModelMemoryLimit = !firstUpdate.current || !modelMemoryLimit;
const shouldUpdateModelMemoryLimit =
(!firstUpdate.current || !modelMemoryLimit) && useEstimatedMml === true;
const shouldUpdateEstimatedMml =
!firstUpdate.current || !modelMemoryLimit || estimatedModelMemoryLimit === '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface State {
sourceIndexFieldsCheckFailed: boolean;
standardizationEnabled: undefined | string;
trainingPercent: number;
useEstimatedMml: boolean;
};
disabled: boolean;
indexPatternsMap: SourceIndexMap;
Expand Down Expand Up @@ -161,6 +162,7 @@ export const getInitialState = (): State => ({
sourceIndexFieldsCheckFailed: false,
standardizationEnabled: 'true',
trainingPercent: 80,
useEstimatedMml: true,
},
jobConfig: {},
disabled:
Expand Down

0 comments on commit 7349897

Please sign in to comment.