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

[ML] DF Analytics creation: ensure advanced editor validates model memory unit correctly #54011

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ml/common/util/job_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export function validateModelMemoryLimitUnits(modelMemoryLimit) {
let valid = true;

if (modelMemoryLimit !== undefined) {
const mml = modelMemoryLimit.toUpperCase();
const mml = String(modelMemoryLimit).toUpperCase();
const mmlSplit = mml.match(/\d+(\w+)$/);
const unit = mmlSplit && mmlSplit.length === 2 ? mmlSplit[1] : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,11 @@ describe('useCreateAnalyticsForm', () => {
validateAdvancedEditor(getMockState({ index: 'the-source-index', modelMemoryLimit: '' }))
.isValid
).toBe(false);
// can still run validation check on model_memory_limit if number type
expect(
// @ts-ignore number is not assignable to type string - mml gets converted to string prior to creation
validateAdvancedEditor(getMockState({ index: 'the-source-index', modelMemoryLimit: 100 }))
.isValid
).toBe(false);
});
});