-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Validate manual model memory input #59056
Conversation
Pinging @elastic/ml-ui (:ml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM.
@@ -222,6 +261,32 @@ export const validateAdvancedEditor = (state: State): State => { | |||
return state; | |||
}; | |||
|
|||
function validateMinMML(estimatedMml: string) { | |||
return (mml: string) => { | |||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these ts-ignore
s for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a typing issue with @elastic/numeral'
, it complains about non-existing value
Code looks good overall! 😄Just a couple of comments. Once the mml has been automatically calculated if a lower number is manually input the Adding space at the end of the manual input causes the regex check for validity to fail. Maybe just trim whitespace from the input string before doing the check? |
@alvarezmelissa87 thanks for the review Melissa, good catch with memory input validation! I removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing this, I'm thinking it might be a simpler workflow to clear the MML input whenever one of the inputs that could affect the estimate changes, rather than trying to persist the previous MML value.
if (errorKey === 'min') { | ||
acc.push( | ||
i18n.translate('xpack.ml.dataframe.analytics.create.modelMemoryUnitsMinError', { | ||
defaultMessage: 'Model memory limit can not be lower than {mml}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, would use cannot
here.
export function validateMinMML(estimatedMml: string) { | ||
return (mml: string) => { | ||
// @ts-ignore | ||
const mmlInBytes = numeral(mml.toUpperCase()).value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10b266f
to
b42b65c
Compare
Looks good overall, @darnautov 😄 The only issue I can see is when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest changes LGTM ⚡️
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested latest edits and LGTM
* [ML] validate mml based on estimated value * [ML] better memoize * [ML] memoryInputValidator unit tests * [ML] cache mml errors * [ML] prevent override * [ML] fix validators, add unit tests * [ML] ignore typing issue with numeral * [ML] fix validateMinMML * [ML] fix useCreateAnalyticsForm test * [ML] setEstimatedModelMemoryLimit to the fallback value in case of an error
* [ML] validate mml based on estimated value * [ML] better memoize * [ML] memoryInputValidator unit tests * [ML] cache mml errors * [ML] prevent override * [ML] fix validators, add unit tests * [ML] ignore typing issue with numeral * [ML] fix validateMinMML * [ML] fix useCreateAnalyticsForm test * [ML] setEstimatedModelMemoryLimit to the fallback value in case of an error
Summary
Resolves #58607. Prevents MML user's manual input override by the result from
_explain
API and adds extra validator for MML input.Checklist