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

akshayrai09 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 2af8d8e  [TE] pinot - harleyjj/detectionutils - return current when 
predicted baseline cannot be trained (#5736)
2af8d8e is described below

commit 2af8d8ee8b6a7587d988d29453379ecc375e5997
Author: Harley Jackson <hjack...@linkedin.com>
AuthorDate: Fri Jul 24 15:06:10 2020 -0700

    [TE] pinot - harleyjj/detectionutils - return current when predicted 
baseline cannot be trained (#5736)
    
    *When detection/predicted-baseline/{anomalyId} endpoint is called and there 
is insufficient data to generate the baseline,
    an error is currently returned.
    *This fix returns the current time series instead, so that data will still 
be displayed in the graph.
---
 .../apache/pinot/thirdeye/detection/DetectionUtils.java  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
index 4352d1a..f0eeb2f 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionUtils.java
@@ -252,6 +252,7 @@ public class DetectionUtils {
       long start, long end, DetectionPipelineLoader loader, DataProvider 
provider) throws Exception {
     String baselineProviderComponentName = 
anomaly.getProperties().get(PROP_BASELINE_PROVIDER_COMPONENT_NAME);
     BaselineProvider baselineProvider = new RuleBaselineProvider();
+    TimeSeries returnTimeSeries;
 
     if (baselineProviderComponentName != null && config != null &&
         config.getComponentSpecs().containsKey(baselineProviderComponentName)) 
{
@@ -265,7 +266,20 @@ public class DetectionUtils {
       InputDataFetcher dataFetcher = new DefaultInputDataFetcher(provider, 
config.getId());
       baselineProvider.init(spec, dataFetcher);
     }
-    return 
baselineProvider.computePredictedTimeSeries(MetricSlice.from(metricId, start, 
end, filters));
+
+    try {
+      returnTimeSeries = 
baselineProvider.computePredictedTimeSeries(MetricSlice.from(metricId, start, 
end, filters));
+    } catch (Exception e) {
+      // send current if the predicted baseline can't be trained
+      BaselineProvider alternateProvider = new RuleBaselineProvider();
+      RuleBaselineProviderSpec spec = new RuleBaselineProviderSpec();
+      spec.setOffset("current");
+      InputDataFetcher dataFetcher = new DefaultInputDataFetcher(provider, 
config.getId());
+      alternateProvider.init(spec, dataFetcher);
+      returnTimeSeries = 
alternateProvider.computePredictedTimeSeries(MetricSlice.from(metricId, start, 
end, filters));
+    }
+
+    return returnTimeSeries;
   }
 
   /**


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

Reply via email to