jihaozh commented on a change in pull request #4369: [TE] Bug Fix - Inject the 
correct metric ref in component spec
URL: https://github.com/apache/incubator-pinot/pull/4369#discussion_r297892211
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/yaml/DetectionConfigTuner.java
 ##########
 @@ -103,12 +99,13 @@ public DetectionConfigTuner(DetectionConfigDTO config, 
DataProvider dataProvider
     Tunable tunable = instantiateTunable(componentClassName, yamlParams, 
dataFetcher);
 
     // round to daily boundary
-    String metricName = componentProps.get(PROP_METRIC).toString();
-    String datasetName = componentProps.get(PROP_DATASET).toString();
-    MetricConfigDTO metricConfig = dataProvider.fetchMetric(metricName, 
datasetName);
-    DatasetConfigDTO datasetConfig = 
dataProvider.fetchDatasets(Collections.singletonList(metricConfig.getDataset()))
-        .get(metricConfig.getDataset());
-    String metricUrn = 
MetricEntity.fromMetric(ConfigUtils.getMap(componentProps.get(PROP_FILTERS)), 
metricConfig.getId()).getUrn();
+    Preconditions.checkNotNull(componentProps.get(PROP_METRIC_URN));
+    String metricUrn = componentProps.get(PROP_METRIC_URN).toString();
+    MetricEntity metricEntity = MetricEntity.fromURN(metricUrn);
+    Map<Long, MetricConfigDTO> metricConfigMap = 
dataProvider.fetchMetrics(Collections.singleton(metricEntity.getId()));
+    Preconditions.checkArgument(metricConfigMap.size() == 1, "Unable to find 
the metric to tune");
+
+    DatasetConfigDTO datasetConfig = 
metricConfigMap.values().iterator().next().getDatasetConfig();
 
 Review comment:
   In my memory, ` metricConfig.getDatasetConfig()` won't return the dataset 
config due to legacy problems. Have to do
   ```
   dataProvider.fetchDatasets(Collection.signleton(metric.getDataset()))
   ```

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to