Skip to content

Commit 7330d0d

Browse files
[ML] DF Analytics: update memory estimate after adding exclude fields (#62850)
* update mml estimate when excludes changes * ensure manually input mml is validated once estimated mml loads
1 parent e5dad99 commit 7330d0d

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

  • x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/create_analytics_form/create_analytics_form.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
5555
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
5656
const { setFormState, setEstimatedModelMemoryLimit } = actions;
5757
const mlContext = useMlContext();
58-
const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state;
58+
const {
59+
estimatedModelMemoryLimit,
60+
form,
61+
indexPatternsMap,
62+
isAdvancedEditorEnabled,
63+
isJobCreated,
64+
requestMessages,
65+
} = state;
5966

6067
const forceInput = useRef<HTMLInputElement | null>(null);
6168
const firstUpdate = useRef<boolean>(true);
@@ -152,6 +159,9 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
152159

153160
const debouncedGetExplainData = debounce(async () => {
154161
const shouldUpdateModelMemoryLimit = !firstUpdate.current || !modelMemoryLimit;
162+
const shouldUpdateEstimatedMml =
163+
!firstUpdate.current || !modelMemoryLimit || estimatedModelMemoryLimit === '';
164+
155165
if (firstUpdate.current) {
156166
firstUpdate.current = false;
157167
}
@@ -167,13 +177,12 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
167177
const jobConfig = getJobConfigFromFormState(form);
168178
delete jobConfig.dest;
169179
delete jobConfig.model_memory_limit;
170-
delete jobConfig.analyzed_fields;
171180
const resp: DfAnalyticsExplainResponse = await ml.dataFrameAnalytics.explainDataFrameAnalytics(
172181
jobConfig
173182
);
174183
const expectedMemoryWithoutDisk = resp.memory_estimation?.expected_memory_without_disk;
175184

176-
if (shouldUpdateModelMemoryLimit) {
185+
if (shouldUpdateEstimatedMml) {
177186
setEstimatedModelMemoryLimit(expectedMemoryWithoutDisk);
178187
}
179188

@@ -340,7 +349,14 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
340349
return () => {
341350
debouncedGetExplainData.cancel();
342351
};
343-
}, [jobType, sourceIndex, sourceIndexNameEmpty, dependentVariable, trainingPercent]);
352+
}, [
353+
jobType,
354+
sourceIndex,
355+
sourceIndexNameEmpty,
356+
dependentVariable,
357+
trainingPercent,
358+
JSON.stringify(excludes),
359+
]);
344360

345361
// Temp effect to close the context menu popover on Clone button click
346362
useEffect(() => {

0 commit comments

Comments
 (0)