-
Notifications
You must be signed in to change notification settings - Fork 18
Adds window size as advanced setting in model configuration. #287
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,15 @@ import { | |
EuiIcon, | ||
EuiButton, | ||
EuiEmptyPrompt, | ||
EuiSpacer, | ||
} from '@elastic/eui'; | ||
import { | ||
Detector, | ||
FEATURE_TYPE, | ||
FeatureAttributes, | ||
} from '../../../models/interfaces'; | ||
import { get, sortBy } from 'lodash'; | ||
import { PLUGIN_NAME } from '../../../utils/constants'; | ||
import { PLUGIN_NAME, SHINGLE_SIZE } from '../../../utils/constants'; | ||
import ContentPanel from '../../../components/ContentPanel/ContentPanel'; | ||
import { CodeModal } from '../components/CodeModal/CodeModal'; | ||
import { getTitleWithCount } from '../../../utils/utils'; | ||
|
@@ -93,6 +94,7 @@ export class Features extends Component<FeaturesProps, FeaturesState> { | |
|
||
public render() { | ||
const featureAttributes = get(this.props.detector, 'featureAttributes', []); | ||
const shingleSize = get(this.props.detector, 'shingleSize', SHINGLE_SIZE); | ||
|
||
const sorting = { | ||
sort: { | ||
|
@@ -170,7 +172,7 @@ export class Features extends Component<FeaturesProps, FeaturesState> { | |
}, | ||
{ | ||
field: 'state', | ||
name: 'State', | ||
name: 'Feature state', | ||
}, | ||
]; | ||
|
||
|
@@ -182,17 +184,21 @@ export class Features extends Component<FeaturesProps, FeaturesState> { | |
|
||
const featureNum = Object.keys(featureAttributes).length; | ||
|
||
const setParamsText = `Set the index fields that you want to find anomalies for by defining | ||
the model features. You can also set other model parameters such as | ||
window size.` | ||
|
||
const previewText = `After you set the model features and other optional parameters, you can | ||
preview your anomalies from a sample feature output.` | ||
Comment on lines
+187
to
+192
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these wordings reviewed by tech writer? Also, since those are constants, you may name it like SET_PARAMS_TEXT = '....' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wording is based exactly on the UX mockups. I can ask the UX designer if the mockups were reviewed by a tech writer. Sure, I will change the variable names for these constants. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The UX designer confirmed that the mockups have been reviewed by a tech writer. |
||
|
||
return ( | ||
<ContentPanel | ||
title={getTitleWithCount('Features', featureNum)} | ||
title="Model configuration" | ||
titleSize="s" | ||
subTitle={ | ||
<EuiText className="anomaly-distribution-subtitle"> | ||
<p> | ||
Specify index fields that you want to find anomalies for by | ||
defining features. A detector can discover anomalies for up to 5 | ||
features. Once you define the features, you can preview your | ||
anomalies from a sample feature output.{' '} | ||
{`${setParamsText} ${previewText} `} | ||
<EuiLink | ||
href="https://opendistro.github.io/for-elasticsearch-docs/docs/ad/" | ||
target="_blank" | ||
|
@@ -211,14 +217,15 @@ export class Features extends Component<FeaturesProps, FeaturesState> { | |
<EuiEmptyPrompt | ||
title={ | ||
<span className="emptyFeatureTitle"> | ||
Features are required to run a detector | ||
Model parameters are required to run a detector | ||
</span> | ||
} | ||
body={ | ||
<EuiText className="emptyFeatureBody"> | ||
Specify index fields that you want to find anomalies for by | ||
defining features. Once you define the features, you can preview | ||
your anomalies from a sample feature output. | ||
{setParamsText} | ||
<br/> | ||
<br/> | ||
{previewText} | ||
</EuiText> | ||
} | ||
actions={[ | ||
|
@@ -227,18 +234,37 @@ export class Features extends Component<FeaturesProps, FeaturesState> { | |
href={`${PLUGIN_NAME}#/detectors/${this.props.detectorId}/features`} | ||
fill | ||
> | ||
Add feature | ||
Configure model | ||
</EuiButton>, | ||
]} | ||
/> | ||
) : ( | ||
<EuiBasicTable | ||
items={sortedItems} | ||
columns={columns} | ||
cellProps={getCellProps} | ||
sorting={sorting} | ||
onChange={this.handleTableChange} | ||
/> | ||
<div> | ||
<ContentPanel | ||
title={getTitleWithCount('Features', featureNum)} | ||
titleSize="s" | ||
> | ||
<EuiBasicTable | ||
items={sortedItems} | ||
columns={columns} | ||
cellProps={getCellProps} | ||
sorting={sorting} | ||
onChange={this.handleTableChange} | ||
/> | ||
</ContentPanel> | ||
<EuiSpacer size="m"/> | ||
<ContentPanel | ||
title="Additional settings" | ||
titleSize="s" | ||
> | ||
<EuiBasicTable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll reach out to the UX designer to clarify. In the mockups, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I synced up with the UX designer, and we will change the Advanced settings to be a content panel nested inside the Model configuration panel rather than a table. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, content panel should be good. Be sure to put both features and advanced setting to nested content panels. |
||
className="header-single-value-euiBasicTable" | ||
items={[{ windowSize: shingleSize }]} | ||
columns={[{ field: 'windowSize', name: 'Window size'}]} | ||
cellProps={getCellProps} | ||
/> | ||
</ContentPanel> | ||
</div> | ||
)} | ||
</ContentPanel> | ||
); | ||
|
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.
Is
shingleSize
optional for backend Java Detector class? If yes, suggest to setshingleSize=8
for java detector instance.So if we change the default SHINGLE_SIZE in future, we don't need to worry about the backward compatibility about old detectors. For example, user create detector with default SHINGLE_SIZE 8 now, later we change the default SHINGLE_SIZE as 4. If we don't set this detector's shingle size as 8 in data model, we may reset it as 4, and model will fail as checkpoint can't match current detector shingle size configuration.
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.
Could you clarify what change you're suggesting in the frontend code? Are you suggesting the SHINGLE_SIZE constant be removed from the frontend?
The
shingleSize
parameter is optional in the API, and the backend already defaults the shingle size to 8 if the parameter is not provided in the request. However, this change will only be applied to detectors which get created or updated after this backend change was made.The reason the default shingle size is also specified in the frontend is precisely for backwards-compatibility. Detectors that were created prior to the recent backend change and have not been updated since then will not have a "shingleSize" field in the stored detector configuration, and it would not be a good user experience to see a "null" or blank in the Window Size field when they view their model configurations in the UI. Even if there is no "shingleSize" field stored on the detector configuration, the user should be informed by the UI that a shingle size of 8 is being used for that detector. In addition, the shingle size needs to be known by the frontend to calculate detector initialization time (see
isDetectorInitOverTime
). (The SHINGLE_SIZE constant was actually already existing in the code for this reason. This constant did not get added in this change.)If they save any changes on the model configuration page for the existing detector, even if they didn't change the window size, going forward the "shingleSize" field will get stored on the detector configuration for the future, but until all existing detectors have been updated to have that field, the default value is needed to ensure the model configuration display the correct value and calculates the correct detector initialization time.
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.
As I said "suggest to set shingleSize=8 for java detector instance." now you have already set it as 8, "the backend already defaults the shingle size to 8 if the parameter is not provided in the request". So that will be ok.