mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Fixes check for lower memory limit. (#24323)
- Fixes the job validation for the lower bound of the model memory limit. Previously the check was against zero, now it's again less than 1MB, which is the same as the backend expects. - If the user entered model memory limit is less than half the value of the estimated model memory limit, a warning type message gets triggered. If the user entered model memory limit is more than half the value but less then the actual value of the estimated model memory limit, then the already existing info type message is shown. The unit tests have been updated to reflect that behavior.
This commit is contained in:
parent
f894f0ea62
commit
836b1a16d2
3 changed files with 77 additions and 5 deletions
|
@ -158,7 +158,7 @@ describe('ML - validateModelMemoryLimit', () => {
|
|||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['estimated_mml_greater_than_mml']);
|
||||
expect(ids).to.eql(['half_estimated_mml_greater_than_mml']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -173,7 +173,7 @@ describe('ML - validateModelMemoryLimit', () => {
|
|||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['estimated_mml_greater_than_mml']);
|
||||
expect(ids).to.eql(['half_estimated_mml_greater_than_mml']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -262,4 +262,60 @@ describe('ML - validateModelMemoryLimit', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('Called with specified invalid mml of "1023KB"', () => {
|
||||
const dtrs = createDetectors(1);
|
||||
const job = getJobConfig(['instance'], dtrs);
|
||||
const duration = { start: 0, end: 1 };
|
||||
job.analysis_limits.model_memory_limit = '1023KB';
|
||||
|
||||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['mml_value_invalid']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('Called with specified valid mml of "1024KB", still triggers a warning', () => {
|
||||
const dtrs = createDetectors(1);
|
||||
const job = getJobConfig(['instance'], dtrs);
|
||||
const duration = { start: 0, end: 1 };
|
||||
job.analysis_limits.model_memory_limit = '1024KB';
|
||||
|
||||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['half_estimated_mml_greater_than_mml']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('Called with specified valid mml of "6MB", still triggers info', () => {
|
||||
const dtrs = createDetectors(1);
|
||||
const job = getJobConfig(['instance'], dtrs);
|
||||
const duration = { start: 0, end: 1 };
|
||||
job.analysis_limits.model_memory_limit = '6MB';
|
||||
|
||||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['half_estimated_mml_greater_than_mml']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('Called with specified valid mml of "20MB", triggers success message', () => {
|
||||
const dtrs = createDetectors(1);
|
||||
const job = getJobConfig(['instance'], dtrs);
|
||||
const duration = { start: 0, end: 1 };
|
||||
job.analysis_limits.model_memory_limit = '20MB';
|
||||
|
||||
return validateModelMemoryLimit(callWithRequest, job, duration).then(
|
||||
(messages) => {
|
||||
const ids = messages.map(m => m.id);
|
||||
expect(ids).to.eql(['success_mml']);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -179,11 +179,18 @@
|
|||
},
|
||||
"mml_value_invalid": {
|
||||
"status": "ERROR",
|
||||
"text": "{{mml}} is not a valid value for model memory limit. The value should be specified in bytes e.g. 10MB"
|
||||
"text": "{{mml}} is not a valid value for model memory limit. The value needs to be at least 1MB and should be specified in bytes e.g. 10MB.",
|
||||
"url": "https://www.elastic.co/guide/en/kibana/{{version}}/job-tips.html#model-memory-limits"
|
||||
},
|
||||
"half_estimated_mml_greater_than_mml": {
|
||||
"status": "WARNING",
|
||||
"text": "The specified model memory limit is less than half of the estimated model memory limit and will likely hit the hard limit.",
|
||||
"url": "https://www.elastic.co/guide/en/kibana/{{version}}/job-tips.html#model-memory-limits"
|
||||
},
|
||||
"estimated_mml_greater_than_mml": {
|
||||
"status": "INFO",
|
||||
"text": "The estimated model memory limit is greater than the model memory limit you have configured."
|
||||
"text": "The estimated model memory limit is greater than the model memory limit you have configured.",
|
||||
"url": "https://www.elastic.co/guide/en/kibana/{{version}}/job-tips.html#model-memory-limits"
|
||||
},
|
||||
"success_mml": {
|
||||
"status": "SUCCESS",
|
||||
|
|
|
@ -11,6 +11,9 @@ import { validateJobObject } from './validate_job_object';
|
|||
import { calculateModelMemoryLimitProvider } from '../../models/calculate_model_memory_limit';
|
||||
import { ALLOWED_DATA_UNITS } from '../../../common/constants/validation';
|
||||
|
||||
// The minimum value the backend expects is 1MByte
|
||||
const MODEL_MEMORY_LIMIT_MINIMUM_BYTES = 1048576;
|
||||
|
||||
export async function validateModelMemoryLimit(callWithRequest, job, duration) {
|
||||
validateJobObject(job);
|
||||
|
||||
|
@ -116,11 +119,17 @@ export async function validateModelMemoryLimit(callWithRequest, job, duration) {
|
|||
// the max mml
|
||||
if (runEstimateGreaterThenMml && mml !== null) {
|
||||
const mmlBytes = numeral(mml).value();
|
||||
if (mmlBytes === 0) {
|
||||
if (mmlBytes < MODEL_MEMORY_LIMIT_MINIMUM_BYTES) {
|
||||
messages.push({
|
||||
id: 'mml_value_invalid',
|
||||
mml
|
||||
});
|
||||
} else if ((mmlEstimateBytes / 2) > mmlBytes) {
|
||||
messages.push({
|
||||
id: 'half_estimated_mml_greater_than_mml',
|
||||
maxModelMemoryLimit,
|
||||
mml
|
||||
});
|
||||
} else if (mmlEstimateBytes > mmlBytes) {
|
||||
messages.push({
|
||||
id: 'estimated_mml_greater_than_mml',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue