[ML] Adds an mml check to trigger an error when mml value is invalid. (#18678) (#18711)

This adds an additional check and corresponding error message to the validation of the model memory limit. If the parsing of the memory model limit results in 0 bytes the message will be triggered. This behaviour catches both correctly formatted but invalid strings (like 0mb) and invalid strings (like asdf).
This commit is contained in:
Walter Rafelsberger 2018-05-02 18:53:27 +02:00 committed by GitHub
parent e19a951594
commit 895249f1d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -192,4 +192,32 @@ describe('ML - validateModelMemoryLimit', () => {
);
});
it('Called with specified invalid mml of "0mb"', () => {
const dtrs = createDetectors(1);
const job = getJobConfig(['instance'], dtrs);
const duration = { start: 0, end: 1 };
job.analysis_limits.model_memory_limit = '0mb';
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 invalid mml of "asdf"', () => {
const dtrs = createDetectors(1);
const job = getJobConfig(['instance'], dtrs);
const duration = { start: 0, end: 1 };
job.analysis_limits.model_memory_limit = 'asdf';
return validateModelMemoryLimit(callWithRequest, job, duration).then(
(messages) => {
const ids = messages.map(m => m.id);
expect(ids).to.eql(['mml_value_invalid']);
}
);
});
});

View file

@ -151,6 +151,10 @@
"status": "ERROR",
"text": "The model memory limit is greater than the max model memory limit configured for this cluster."
},
"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"
},
"estimated_mml_greater_than_mml": {
"status": "INFO",
"text": "The estimated model memory limit is greater than the model memory limit you have configured."

View file

@ -96,7 +96,12 @@ export async function validateModelMemoryLimit(callWithRequest, job, duration) {
// the max mml
if (runEstimateGreaterThenMml && mml !== null) {
const mmlBytes = numeral(mml).value();
if (mmlEstimateBytes > mmlBytes) {
if (mmlBytes === 0) {
messages.push({
id: 'mml_value_invalid',
mml
});
} else if (mmlEstimateBytes > mmlBytes) {
messages.push({
id: 'estimated_mml_greater_than_mml',
maxModelMemoryLimit,