@@ -18,6 +18,7 @@ import {
1818 EuiLink ,
1919 EuiSelect ,
2020 EuiSpacer ,
21+ EuiSwitch ,
2122 EuiTitle ,
2223} from '@elastic/eui' ;
2324import { i18n } from '@kbn/i18n' ;
@@ -138,7 +139,7 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
138139 const { ELASTIC_WEBSITE_URL , DOC_LINK_VERSION } = docLinks ;
139140
140141 const { setEstimatedModelMemoryLimit, setFormState } = actions ;
141- const { form, isJobCreated } = state ;
142+ const { form, isJobCreated, estimatedModelMemoryLimit , cloneJob } = state ;
142143 const {
143144 computeFeatureInfluence,
144145 eta,
@@ -161,6 +162,8 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
161162 randomizeSeed,
162163 } = form ;
163164
165+ const [ useEstimatedMml , setUseEstimatedMml ] = useState < boolean > ( cloneJob === undefined ) ;
166+
164167 const [ numTopClassesOptions , setNumTopClassesOptions ] = useState < EuiComboBoxOptionOption [ ] > ( [
165168 defaultNumTopClassesOption ,
166169 ] ) ;
@@ -204,7 +207,9 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
204207 if ( success ) {
205208 if ( modelMemoryLimit !== expectedMemory ) {
206209 setEstimatedModelMemoryLimit ( expectedMemory ) ;
207- setFormState ( { modelMemoryLimit : expectedMemory } ) ;
210+ if ( useEstimatedMml === true ) {
211+ setFormState ( { modelMemoryLimit : expectedMemory } ) ;
212+ }
208213 }
209214 } else {
210215 // Check which field is invalid
@@ -481,18 +486,31 @@ export const AdvancedStepForm: FC<CreateAnalyticsStepProps> = ({
481486 }
482487 ) }
483488 >
484- < EuiFieldText
485- placeholder = {
486- jobType !== undefined
487- ? DEFAULT_MODEL_MEMORY_LIMIT [ jobType ]
488- : DEFAULT_MODEL_MEMORY_LIMIT . outlier_detection
489- }
490- disabled = { isJobCreated }
491- value = { modelMemoryLimit || '' }
492- onChange = { ( e ) => setFormState ( { modelMemoryLimit : e . target . value } ) }
493- isInvalid = { modelMemoryLimitValidationResult !== null }
494- data-test-subj = "mlAnalyticsCreateJobWizardModelMemoryInput"
495- />
489+ < >
490+ < EuiFieldText
491+ placeholder = {
492+ jobType !== undefined
493+ ? DEFAULT_MODEL_MEMORY_LIMIT [ jobType ]
494+ : DEFAULT_MODEL_MEMORY_LIMIT . outlier_detection
495+ }
496+ disabled = { isJobCreated || useEstimatedMml }
497+ value = { useEstimatedMml ? estimatedModelMemoryLimit : modelMemoryLimit || '' }
498+ onChange = { ( e ) => setFormState ( { modelMemoryLimit : e . target . value } ) }
499+ isInvalid = { modelMemoryLimitValidationResult !== null }
500+ data-test-subj = "mlAnalyticsCreateJobWizardModelMemoryInput"
501+ />
502+ < EuiSpacer size = "xs" />
503+ < EuiSwitch
504+ disabled = { isJobCreated }
505+ name = "mlDataFrameAnalyticsUseEstimatedMml"
506+ label = { i18n . translate ( 'xpack.ml.dataframe.analytics.create.UseEstimatedMmlLabel' , {
507+ defaultMessage : 'Use estimated model memory limit' ,
508+ } ) }
509+ checked = { useEstimatedMml === true }
510+ onChange = { ( ) => setUseEstimatedMml ( ! useEstimatedMml ) }
511+ data-test-subj = "mlAnalyticsCreateJobWizardUseEstimatedMml"
512+ />
513+ </ >
496514 </ EuiFormRow >
497515 </ EuiFlexItem >
498516 < EuiFlexItem >
0 commit comments