Skip to content

Commit

Permalink
Moved logic to select results into perfProfiles.
Browse files Browse the repository at this point in the history
Signed-off-by: msvinaykumar <[email protected]>
  • Loading branch information
msvinaykumar committed Jun 16, 2023
1 parent 097f25b commit 1febe68
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*******************************************************************************/
package com.autotune.analyzer.experiment;

import com.autotune.analyzer.kruizeObject.KruizeObject;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.analyzer.performanceProfiles.PerformanceProfileInterface.PerfProfileInterface;
import com.autotune.analyzer.utils.AnalyzerConstants;
import com.autotune.common.data.ValidationOutputData;
import com.autotune.common.data.result.ExperimentResultData;
import com.autotune.analyzer.kruizeObject.KruizeObject;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -99,34 +99,18 @@ public ValidationOutputData validateAndUpdateResults(
}

// Generate recommendations and add it to the kruize object
public boolean generateAndAddRecommendations(Map<String, KruizeObject> experimentsMap, List<ExperimentResultData> experimentResultDataList) {
if (null == experimentResultDataList)
return false;
if (experimentResultDataList.size() == 0)
return false;
for (ExperimentResultData experimentResultData: experimentResultDataList) {
// TODO: Log the list of invalid experiments and return the error instead of bailing out completely
if (!experimentsMap.containsKey(experimentResultData.getExperiment_name())) {
LOGGER.error("Trying to locate Recommendation for non existent experiment: " +
experimentResultData.getExperiment_name());
continue;
}
KruizeObject kruizeObject = experimentsMap.get(experimentResultData.getExperiment_name());
if (AnalyzerConstants.PerformanceProfileConstants.perfProfileInstances.containsKey(kruizeObject.getPerformanceProfile())) {
try {
PerfProfileInterface perfProfileInstance =
(PerfProfileInterface) AnalyzerConstants.PerformanceProfileConstants
.perfProfileInstances.get(kruizeObject.getPerformanceProfile())
.getDeclaredConstructor().newInstance();
perfProfileInstance.generateRecommendation(kruizeObject, experimentResultData);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e ) {
e.printStackTrace();
}
} else {
LOGGER.error("No Recommendation Engine mapping found for performance profile: " +
kruizeObject.getPerformanceProfile() + ". Cannot process recommendations for the experiment");
}
public void generateAndAddRecommendations(KruizeObject kruizeObject, List<ExperimentResultData> experimentResultDataList, Timestamp interval_start_time, Timestamp interval_end_time) throws Exception {
if (AnalyzerConstants.PerformanceProfileConstants.perfProfileInstances.containsKey(kruizeObject.getPerformanceProfile())) {
PerfProfileInterface perfProfileInstance =
(PerfProfileInterface) AnalyzerConstants.PerformanceProfileConstants
.perfProfileInstances.get(kruizeObject.getPerformanceProfile())
.getDeclaredConstructor().newInstance();
perfProfileInstance.generateRecommendation(kruizeObject, experimentResultDataList, interval_start_time, interval_end_time);
} else {
throw new Exception("No Recommendation Engine mapping found for performance profile: " +
kruizeObject.getPerformanceProfile() + ". Cannot process recommendations for the experiment");
}
return true;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
package com.autotune.analyzer.performanceProfiles.PerformanceProfileInterface;

import com.autotune.analyzer.kruizeObject.KruizeObject;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.analyzer.performanceProfiles.utils.PerformanceProfileUtil;
import com.autotune.analyzer.recommendations.engine.KruizeRecommendationEngine;
import com.autotune.analyzer.utils.AnalyzerConstants;
import com.autotune.common.data.metrics.Metric;
import com.autotune.common.data.metrics.MetricResults;
import com.autotune.common.data.result.*;
import com.autotune.common.data.result.ContainerData;
import com.autotune.analyzer.recommendations.engine.KruizeRecommendationEngine;
import com.autotune.common.data.result.ExperimentResultData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;

/**
* Util class to validate the performance profile metrics with the experiment results metrics.
Expand All @@ -43,10 +40,6 @@ private String validateValues(HashMap<String, MetricResults> funcVar, List<Strin
return "";
}

@Override
public void generateRecommendation(KruizeObject kruizeObject, ExperimentResultData experimentResultData) {

}

// TODO: Update these based on requirements, currently leaving Invalid as Default impl doesn't need engine
@Override
Expand All @@ -59,4 +52,9 @@ public AnalyzerConstants.RegisterRecommendationEngineStatus registerEngine(Kruiz
public List<KruizeRecommendationEngine> getEngines() {
return null;
}

@Override
public void generateRecommendation(KruizeObject kruizeObject, List<ExperimentResultData> experimentResultDataList, Timestamp interval_start_time, Timestamp interval_end_time) {

}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*******************************************************************************
* Copyright (c) 2022 Red Hat, IBM Corporation and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -20,12 +17,17 @@
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.common.data.result.ExperimentResultData;

import java.sql.Timestamp;
import java.util.List;

/**
* Abstraction layer containing methods for the validation of the Performance Profiles with respect to the updated experiment.
* and to parse the objective function data.
*/
public interface PerfProfileInterface {
// name, validateResults, validateProfile, recommend
// name, validateResults, validateProfile, recommend
String getName(PerformanceProfile profile);
void generateRecommendation(KruizeObject kruizeObject, ExperimentResultData experimentResultData);

void generateRecommendation(KruizeObject kruizeObject, List<ExperimentResultData> experimentResultDataList, Timestamp interval_start_time, Timestamp interval_end_time) throws Exception;

}
Loading

0 comments on commit 1febe68

Please sign in to comment.