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] Validate manual model memory input #59056

Merged
merged 10 commits into from
Mar 4, 2020

Conversation

darnautov
Copy link
Contributor

@darnautov darnautov commented Mar 2, 2020

Summary

Resolves #58607. Prevents MML user's manual input override by the result from _explain API and adds extra validator for MML input.

Mar-02-2020 17-32-10

Checklist

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

@walterra walterra left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these ts-ignores for?

Copy link
Contributor Author

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

@alvarezmelissa87
Copy link
Contributor

Code looks good overall! 😄Just a couple of comments.

Once the mml has been automatically calculated if a lower number is manually input the can't be lower than x error still shows up and doesn't seem to take unit type into account:

image

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?

image

@darnautov
Copy link
Contributor Author

darnautov commented Mar 3, 2020

@alvarezmelissa87 thanks for the review Melissa, good catch with memory input validation! I removed toUpperCase before committing thinking it's redundant, but actually, it's required for numeral to convert values taking units into account. Fixed in 694f606. Also, added a trim for units validator, but we might want to modify the string before sending a payload, don't we? 🤔 Update: backend trims it anyway

Copy link
Contributor

@peteharverson peteharverson left a 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}',
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as I set the job type in the flyout, the page goes blank with the following errors in the console:

image

@alvarezmelissa87
Copy link
Contributor

Looks good overall, @darnautov 😄

The only issue I can see is when _explain returns an error and the default value gets set. If the default is less than the previous estimated value of mml then you get the error message and the create button is disabled still.
Other than that, seems to work as expected 👍

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM ⚡️

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@peteharverson peteharverson left a 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

@darnautov darnautov merged commit 4ce66c6 into elastic:master Mar 4, 2020
@darnautov darnautov deleted the ML-58607-mml-validation branch March 4, 2020 10:02
darnautov added a commit to darnautov/kibana that referenced this pull request Mar 4, 2020
* [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
darnautov added a commit that referenced this pull request Mar 4, 2020
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] DF Analytics - memory estimation overrides manually set value
6 participants