You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ap...@apache.org on 2018/11/21 18:29:23 UTC

[incubator-pinot] branch master updated: [TE] frontend - harleyjj/rootcause - fix data inconsistency warning t… (#3532)

This is an automated email from the ASF dual-hosted git repository.

apucher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 2ce0bca  [TE] frontend - harleyjj/rootcause - fix data inconsistency warning t… (#3532)
2ce0bca is described below

commit 2ce0bca121a90c1c3bec449eab0c4b6eeeb675b2
Author: Harley Jackson <ha...@gmail.com>
AuthorDate: Wed Nov 21 10:29:18 2018 -0800

    [TE] frontend - harleyjj/rootcause - fix data inconsistency warning t… (#3532)
    
    The data inconsistency warning:
    
    -will not be triggered by changing the date range
    -will display only the original values that triggered it (value does not change based on date range)
    -will remain displayed when the user changes the date range, if the original values merit the warning
---
 .../pods/components/rootcause-anomaly/component.js | 57 +++++++++++---
 .../pods/components/rootcause-anomaly/template.hbs |  2 +-
 .../app/pods/rootcause/template.hbs                |  1 +
 .../components/rootcause-anomaly/component-test.js | 91 ++++++++++++++++++----
 4 files changed, 123 insertions(+), 28 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/component.js b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/component.js
index d0d6e5e..b5f15f9 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/component.js
@@ -3,7 +3,8 @@ import {
   computed,
   setProperties,
   getProperties,
-  get
+  get,
+  set
 } from '@ember/object';
 import moment from 'moment';
 import {
@@ -67,12 +68,35 @@ export default Component.extend({
   options: Object.keys(ANOMALY_OPTIONS_MAPPING),
 
   /**
+   * Can be set by isWarning if data inconsistent
+   * @type {boolean}
+   */
+  warningValue: false,
+
+  /**
    * A mapping of the status and a more human readable version
    * @type {Object}
    */
   optionsMapping: ANOMALY_OPTIONS_MAPPING,
 
   /**
+   * Checks if anomalyRange from context is different than anomaly start and end
+   * times
+   * @type {boolean}
+   */
+  isRangeChanged: computed(
+    'anomalyRange',
+    'anomaly',
+    function () {
+      const anomaly = get(this, 'anomaly');
+      const anomalyRange = get(this, 'anomalyRange');
+      const start = get(this, 'anomaly').start;
+      const end = get(this, 'anomaly').end;
+      return !(anomalyRange[0] === start && anomalyRange[1] === end);
+    }
+  ),
+
+  /**
    * Urn of an anomaly
    * @type {String}
    */
@@ -327,19 +351,30 @@ export default Component.extend({
   }),
 
   /**
-   * Checks if param values and displayed values differ by 5% or more
+   * Checks if value at anomaly detection time and present differ by 1% or more
    * @type {Boolean}
    */
-  isWarning: computed('anomalyInfo', function () {
-    const anomalyInfo = get(this, 'anomalyInfo');
-    let oldCurrent = parseFloat(get(this, 'current'));
-    const newCurrent = this._getAggregate('current');
-
-    if (newCurrent && oldCurrent){
-      const diffCurrent = Math.abs((newCurrent-oldCurrent)/newCurrent);
-      return (diffCurrent > 0.01);
+  isWarning: computed('anomalyInfo', 'isRangeChanged', function () {
+    if(!get(this, 'isRangeChanged')) {
+      let oldCurrent = parseFloat(get(this, 'current'));
+      const newCurrent = this._getAggregate('current');
+      if (newCurrent && oldCurrent){
+        const diffCurrent = Math.abs((newCurrent-oldCurrent)/newCurrent);
+        if (diffCurrent > 0.01) {
+          set(this, 'warningValue', true);
+        }
+      }
     }
-    return false;
+    return get(this, 'warningValue');
+  }),
+
+  /**
+   * grabs value of new current only when warningValue is toggled
+   * @type {string}
+   */
+  warningChangedTo: computed('warningValue', function() {
+    const newCurrent = this._getAggregate('current');
+    return humanizeFloat(newCurrent);
   }),
 
   /**
diff --git a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/template.hbs b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/template.hbs
index dc58e23..e396485 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/components/rootcause-anomaly/template.hbs
@@ -56,7 +56,7 @@
       {{#if isWarning}}
       <div class="diffcurrent-alert alert alert-warning fade in">
         <h4><i class="glyphicon glyphicon-exclamation-sign"></i> Data has been changed since anomaly detected</h4>
-        At the time when anomaly was detected, the data has changed from <strong>{{humanizedAnomalyCurrent}}</strong> to <strong>{{get anomalyInfo "current.value"}}</strong>.<br>
+        At the time when anomaly was detected, the data has changed from <strong>{{humanizedAnomalyCurrent}}</strong> to <strong>{{warningChangedTo}}</strong>.<br>
         No action is needed.  Anomaly will be labeled as <strong>Inconsistent Data</strong>.
       </div>
       {{/if}}
diff --git a/thirdeye/thirdeye-frontend/app/pods/rootcause/template.hbs b/thirdeye/thirdeye-frontend/app/pods/rootcause/template.hbs
index a161caf..3b984a1 100644
--- a/thirdeye/thirdeye-frontend/app/pods/rootcause/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/rootcause/template.hbs
@@ -34,6 +34,7 @@
       aggregates=aggregates
       anomalyUrns=context.anomalyUrns
       onFeedback=(action "onFeedback")
+      anomalyRange=context.anomalyRange
     }}
   {{/if}}
 
diff --git a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-anomaly/component-test.js b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-anomaly/component-test.js
index 1a9bd29..4366fd0 100644
--- a/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-anomaly/component-test.js
+++ b/thirdeye/thirdeye-frontend/tests/integration/pods/components/rootcause-anomaly/component-test.js
@@ -7,8 +7,8 @@ import wait from 'ember-test-helpers/wait';
 module('Integration | Component | rootcause-anomaly', function(hooks) {
   setupRenderingTest(hooks);
 
-  test(`displays warning if anomaly function value and displayed value are more than 1
-    percent different`, async function(assert) {
+  test(`displays warning if anomaly function value and displayed value are more
+    than 1 percent different`, async function(assert) {
     this.setProperties({
       entities: {
         'thirdeye:event:anomaly:1': {
@@ -31,14 +31,17 @@ module('Integration | Component | rootcause-anomaly', function(hooks) {
             metricGranularity : [ '5_MINUTES' ],
             dataset : [ 'my_dataset' ],
             status : [ 'NO_FEEDBACK' ]
-          }
+          },
+          start: 0,
+          end: 0
         }
       },
       anomalyUrns: ['thirdeye:event:anomaly:1', 'thirdeye:metric:1'],
       onFeedback: () => {},
       aggregates: {
         'frontend:metric:current:1': 93453.15844726562
-      }
+      },
+      anomalyRange: [0, 0]
     });
 
     await render(hbs`
@@ -47,6 +50,7 @@ module('Integration | Component | rootcause-anomaly', function(hooks) {
         aggregates=aggregates
         anomalyUrns=anomalyUrns
         onFeedback=(action onFeedback)
+        anomalyRange=anomalyRange
       }}
     `);
 
@@ -54,8 +58,8 @@ module('Integration | Component | rootcause-anomaly', function(hooks) {
     assert.ok(this.$('.diffcurrent-alert').length > 0);
   });
 
-  test(`does not display warning if anomaly function value and displayed value are not more than 1
-    percent different`, async function(assert) {
+  test(`does not display warning if anomaly function value and displayed value
+    are not more than 1 percent different`, async function(assert) {
       this.setProperties({
         entities: {
           'thirdeye:event:anomaly:1': {
@@ -78,24 +82,79 @@ module('Integration | Component | rootcause-anomaly', function(hooks) {
               metricGranularity : [ '5_MINUTES' ],
               dataset : [ 'my_dataset' ],
               status : [ 'NO_FEEDBACK' ]
-            }
+            },
+            start: 0,
+            end: 0
           }
         },
         anomalyUrns: ['thirdeye:event:anomaly:1', 'thirdeye:metric:1'],
         onFeedback: () => {},
         aggregates: {
           'frontend:metric:current:1': 93453.15844726562
-        }
+        },
+        anomalyRange: [0, 0]
       });
 
-    await render(hbs`
-      {{rootcause-anomaly
-        entities=entities
-        aggregates=aggregates
-        anomalyUrns=anomalyUrns
-        onFeedback=(action onFeedback)
-      }}
-    `);
+      await render(hbs`
+        {{rootcause-anomaly
+          entities=entities
+          aggregates=aggregates
+          anomalyUrns=anomalyUrns
+          onFeedback=(action onFeedback)
+          anomalyRange=anomalyRange
+        }}
+      `);
+
+    assert.notOk(this.$('.diffcurrent-alert').length > 0);
+  });
+
+  test(`does not display warning if context anomaly range is different than
+    anomaly start and end, even when data differs by more than 1 percent`,
+    async function(assert) {
+      this.setProperties({
+        entities: {
+          'thirdeye:event:anomaly:1': {
+            urn: 'thirdeye:event:anomaly:1',
+            label: 'dataset1::metric1',
+            attributes : {
+              EXTERNAL : [ 'hello' ],
+              weight : [ '0.17679628053981644' ],
+              baseline : [ '3308.878952874078' ],
+              externalUrls : [ 'EXTERNAL' ],
+              statusClassification : [ 'NONE' ],
+              score : [ '0.03195732831954956' ],
+              functionId : [ '1' ],
+              current : [ '3' ],
+              aggregateMultiplier : [ '0.041666666666666664' ],
+              metricId : [ '1' ],
+              metric : [ 'metric' ],
+              function : [ 'function' ],
+              comment : [ '' ],
+              metricGranularity : [ '5_MINUTES' ],
+              dataset : [ 'my_dataset' ],
+              status : [ 'NO_FEEDBACK' ]
+            },
+            start: 0,
+            end: 0
+          }
+        },
+        anomalyUrns: ['thirdeye:event:anomaly:1', 'thirdeye:metric:1'],
+        onFeedback: () => {},
+        aggregates: {
+          'frontend:metric:current:1': 93453.15844726562
+        },
+        anomalyRange: [0, 1]
+      });
+
+      await render(hbs`
+        {{rootcause-anomaly
+          entities=entities
+          aggregates=aggregates
+          anomalyUrns=anomalyUrns
+          onFeedback=(action onFeedback)
+          anomalyRange=anomalyRange
+        }}
+      `);
 
     assert.notOk(this.$('.diffcurrent-alert').length > 0);
   });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org