Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [ML] DF Analytics: update memory estimate after adding exclude fields (#62850) #63125

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = docLinks;
const { setFormState, setEstimatedModelMemoryLimit } = actions;
const mlContext = useMlContext();
const { form, indexPatternsMap, isAdvancedEditorEnabled, isJobCreated, requestMessages } = state;
const {
estimatedModelMemoryLimit,
form,
indexPatternsMap,
isAdvancedEditorEnabled,
isJobCreated,
requestMessages,
} = state;

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

const debouncedGetExplainData = debounce(async () => {
const shouldUpdateModelMemoryLimit = !firstUpdate.current || !modelMemoryLimit;
const shouldUpdateEstimatedMml =
!firstUpdate.current || !modelMemoryLimit || estimatedModelMemoryLimit === '';

if (firstUpdate.current) {
firstUpdate.current = false;
}
Expand All @@ -167,13 +177,12 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
const jobConfig = getJobConfigFromFormState(form);
delete jobConfig.dest;
delete jobConfig.model_memory_limit;
delete jobConfig.analyzed_fields;
const resp: DfAnalyticsExplainResponse = await ml.dataFrameAnalytics.explainDataFrameAnalytics(
jobConfig
);
const expectedMemoryWithoutDisk = resp.memory_estimation?.expected_memory_without_disk;

if (shouldUpdateModelMemoryLimit) {
if (shouldUpdateEstimatedMml) {
setEstimatedModelMemoryLimit(expectedMemoryWithoutDisk);
}

Expand Down Expand Up @@ -340,7 +349,14 @@ export const CreateAnalyticsForm: FC<CreateAnalyticsFormProps> = ({ actions, sta
return () => {
debouncedGetExplainData.cancel();
};
}, [jobType, sourceIndex, sourceIndexNameEmpty, dependentVariable, trainingPercent]);
}, [
jobType,
sourceIndex,
sourceIndexNameEmpty,
dependentVariable,
trainingPercent,
JSON.stringify(excludes),
]);

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