Skip to content

Commit

Permalink
[ML] DF Analytics: update memory estimate after adding exclude fields (
Browse files Browse the repository at this point in the history
…#62850) (#63125)

* update mml estimate when excludes changes

* ensure manually input mml is validated once estimated mml loads
  • Loading branch information
alvarezmelissa87 authored Apr 9, 2020
1 parent f6755a9 commit a917ad1
Showing 1 changed file with 20 additions and 4 deletions.
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

0 comments on commit a917ad1

Please sign in to comment.