-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Add switch to enable model plot annotations independently #70678
Merged
qn895
merged 7 commits into
elastic:master
from
qn895:model-plot-annotations-create-wizard
Jul 9, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7411f7
[ML] Add switch to enable model plot annotations independently
qn895 1b54be9
[ML] Refactor model change annotations
qn895 327c3e2
Merge remote-tracking branch 'upstream/master' into model-plot-annota…
qn895 42d9697
[ML] Update default behavior when page /new_job is loaded
qn895 b49baf1
Merge remote-tracking branch 'upstream/master' into model-plot-annota…
qn895 405c2a7
[ML] Use _initModelPlotConfig
qn895 fcb1bab
[ML] Fix type error, remove Job, shorten set logic
qn895 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...ob_details_step/components/advanced_section/components/annotations/annotations_switch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FC, useState, useContext, useEffect } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiCallOut, EuiSpacer, EuiSwitch } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { JobCreatorContext } from '../../../../../job_creator_context'; | ||
import { Description } from './description'; | ||
|
||
export const AnnotationsSwitch: FC = () => { | ||
const { jobCreator, jobCreatorUpdate, jobCreatorUpdated } = useContext(JobCreatorContext); | ||
const [annotationsEnabled, setAnnotationsEnabled] = useState(jobCreator.modelChangeAnnotations); | ||
const [showCallOut, setShowCallout] = useState( | ||
jobCreator.modelPlot && !jobCreator.modelChangeAnnotations | ||
); | ||
|
||
useEffect(() => { | ||
jobCreator.modelChangeAnnotations = annotationsEnabled; | ||
jobCreatorUpdate(); | ||
}, [annotationsEnabled]); | ||
|
||
useEffect(() => { | ||
setShowCallout(jobCreator.modelPlot && !annotationsEnabled); | ||
}, [jobCreatorUpdated, annotationsEnabled]); | ||
|
||
function toggleAnnotations() { | ||
setAnnotationsEnabled(!annotationsEnabled); | ||
} | ||
|
||
return ( | ||
<> | ||
<Description> | ||
<EuiSwitch | ||
name="switch" | ||
checked={annotationsEnabled} | ||
onChange={toggleAnnotations} | ||
data-test-subj="mlJobWizardSwitchAnnotations" | ||
label={i18n.translate( | ||
'xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlotAnnotations.title', | ||
{ | ||
defaultMessage: 'Enable model change annotations', | ||
} | ||
)} | ||
/> | ||
</Description> | ||
{showCallOut && ( | ||
<EuiCallOut | ||
title={ | ||
<FormattedMessage | ||
id="xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.annotationsSwitchCallout.title" | ||
defaultMessage="If you enable model plot with this configuration, we recommend you also enable annotations." | ||
/> | ||
} | ||
color="primary" | ||
iconType="help" | ||
/> | ||
)} | ||
<EuiSpacer /> | ||
</> | ||
); | ||
}; |
34 changes: 34 additions & 0 deletions
34
...nents/job_details_step/components/advanced_section/components/annotations/description.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo, FC } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiDescribedFormGroup, EuiFormRow } from '@elastic/eui'; | ||
|
||
export const Description: FC = memo(({ children }) => { | ||
const title = i18n.translate( | ||
'xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlotAnnotations.title', | ||
{ | ||
defaultMessage: 'Enable model change annotations', | ||
} | ||
); | ||
return ( | ||
<EuiDescribedFormGroup | ||
title={<h3>{title}</h3>} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlotAnnotations.description" | ||
defaultMessage="Select to generate annotations when the model changes significantly. For example, when step changes, periodicity or trends are detected." | ||
/> | ||
} | ||
> | ||
<EuiFormRow label={title}> | ||
<>{children}</> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
); | ||
}); |
7 changes: 7 additions & 0 deletions
7
...s/components/job_details_step/components/advanced_section/components/annotations/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { AnnotationsSwitch } from './annotations_switch'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do we definitely want to enabling this for all single metric jobs?
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.
I think just enabling
modelPlot
(and omittingmodelChangeAnnotations
) will actually enablemodelChangeAnnotations
as well by default on elastic's side so I thought it would be clearer to statemodelChangeAnnotations
as true on the UI side for consistency.As for why we wanted both on for SM jobs, the discussion was that we expect annotations to be fairly high volume for high cardinality jobs, but nowhere near as high volume as model plot. So if we can tolerate the volume of model plot, we would probably also want annotations.
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.
This is no longer possible with the changes you added in 405c2a7. So if we do want to only enable
modelPlot
this line could be omitted.I was asking more from a product design point of view, whether this had been discussed and it sounds like it has.
I was mainly concerned about the noise of the new annotations that will be generated.