You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pinot.apache.org by GitBox <gi...@apache.org> on 2018/11/21 18:29:20 UTC

[GitHub] apucher closed pull request #3532: [TE] frontend - harleyjj/rootcause - fix data inconsistency warning t…

apucher closed pull request #3532: [TE] frontend - harleyjj/rootcause - fix data inconsistency warning t…
URL: https://github.com/apache/incubator-pinot/pull/3532
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 d0d6e5e284..b5f15f9590 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 {
@@ -66,12 +67,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 dc58e2324a..e396485b40 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 85c9a13178..043b294b27 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 1a9bd29e84..4366fd0f76 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);
   });


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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