Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace PerformanceProfile with MetricProfile #1256

Open
wants to merge 1 commit into
base: mvp_demo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/autotune/analyzer/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.autotune.analyzer;

import com.autotune.analyzer.experiment.Experimentator;
import com.autotune.analyzer.performanceProfiles.PerformanceProfilesDeployment;
import com.autotune.analyzer.metricProfiles.MetricProfilesDeployment;
import com.autotune.analyzer.services.*;
import com.autotune.operator.KruizeDeploymentInfo;
import com.autotune.operator.KruizeOperator;
Expand All @@ -31,7 +31,7 @@ public static void start(ServletContextHandler contextHandler) {

try {
addServlets(contextHandler);
PerformanceProfilesDeployment.getPerformanceProfiles(); // Performance profile should be called first
MetricProfilesDeployment.getMetricProfiles(); // Performance profile should be called first
KruizeOperator.getKruizeObjects(kruizeOperator);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
package com.autotune.analyzer.experiment;

import com.autotune.analyzer.kruizeObject.KruizeObject;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.analyzer.performanceProfiles.PerformanceProfilesDeployment;
import com.autotune.analyzer.metricProfiles.MetricProfile;
import com.autotune.analyzer.recommendations.ContainerRecommendations;
import com.autotune.analyzer.utils.AnalyzerConstants;
import com.autotune.analyzer.utils.AnalyzerErrorConstants;
Expand Down Expand Up @@ -47,7 +46,7 @@ public class ExperimentValidation {
private boolean success;
private String errorMessage;
private Map<String, KruizeObject> mainKruizeExperimentMAP;
private Map<String, PerformanceProfile> performanceProfilesMap = new HashMap<>();
private Map<String, MetricProfile> metricProfilesMap = new HashMap<>();
//Mandatory fields
private List<String> mandatoryFields = new ArrayList<>(Arrays.asList(
AnalyzerConstants.NAME,
Expand Down Expand Up @@ -99,20 +98,20 @@ public void validate(List<KruizeObject> kruizeExptList) {
boolean proceed = false;
String errorMsg = "";
if (null == this.mainKruizeExperimentMAP.get(expName)) {
// check for slo and performance profile
if (null != kruizeObject.getPerformanceProfile()) {
// check for slo and metric profile
if (null != kruizeObject.getMetricProfile()) {
if (null != kruizeObject.getSloInfo()) {
errorMsg = AnalyzerErrorConstants.AutotuneObjectErrors.SLO_REDUNDANCY_ERROR;
validationOutputData.setErrorCode(HttpServletResponse.SC_BAD_REQUEST);
} else {
// fetch the Performance Profile from the DB
try {
new ExperimentDBService().loadPerformanceProfileFromDBByName(performanceProfilesMap, kruizeObject.getPerformanceProfile());
new ExperimentDBService().loadPerformanceProfileFromDBByName(metricProfilesMap, kruizeObject.getMetricProfile());
} catch (Exception e) {
LOGGER.error("Loading saved Performance Profile {} failed: {} ", expName, e.getMessage());
}
if (null == performanceProfilesMap.get(kruizeObject.getPerformanceProfile())) {
errorMsg = AnalyzerErrorConstants.AutotuneObjectErrors.MISSING_PERF_PROFILE + kruizeObject.getPerformanceProfile();
if (null == metricProfilesMap.get(kruizeObject.getMetricProfile())) {
errorMsg = AnalyzerErrorConstants.AutotuneObjectErrors.MISSING_PERF_PROFILE + kruizeObject.getMetricProfile();
validationOutputData.setErrorCode(HttpServletResponse.SC_BAD_REQUEST);
} else
proceed = true;
Expand All @@ -122,8 +121,8 @@ public void validate(List<KruizeObject> kruizeExptList) {
errorMsg = AnalyzerErrorConstants.AutotuneObjectErrors.MISSING_SLO_DATA;
validationOutputData.setErrorCode(HttpServletResponse.SC_BAD_REQUEST);
} else {
String perfProfileName = KruizeOperator.setDefaultPerformanceProfile(kruizeObject.getSloInfo(), mode, target_cluster);
kruizeObject.setPerformanceProfile(perfProfileName);
String metricProfileName = KruizeOperator.setDefaultPerformanceProfile(kruizeObject.getSloInfo(), mode, target_cluster);
kruizeObject.setMetricProfile(metricProfileName);
proceed = true;
}
}
Expand All @@ -144,11 +143,11 @@ public void validate(List<KruizeObject> kruizeExptList) {
markFailed(validationOutputData.getMessage());
break;
}
// set Performance Profile metrics in the Kruize Object
PerformanceProfile performanceProfile = performanceProfilesMap.get(kruizeObject.getPerformanceProfile());
// set Metric Profile metrics in the Kruize Object
MetricProfile metricProfile = metricProfilesMap.get(kruizeObject.getMetricProfile());
try {
HashMap<AnalyzerConstants.MetricName, Metric> metricsMap = new HashMap<>();
for (Metric metric : performanceProfile.getSloInfo().getFunctionVariables()) {
for (Metric metric : metricProfile.getSloInfo().getFunctionVariables()) {
if (metric.getKubernetesObject().equals(KruizeConstants.JSONKeys.CONTAINER))
metricsMap.put(AnalyzerConstants.MetricName.valueOf(metric.getName()), metric);
}
Expand All @@ -164,7 +163,7 @@ public void validate(List<KruizeObject> kruizeExptList) {
}
kruizeObject.setKubernetes_objects(k8sObjectList);
} catch (Exception e) {
LOGGER.error("Failed to set Performance Profile Metrics to the Kruize Object: {}", e.getMessage());
LOGGER.error("Failed to set Metric Profile Metrics to the Kruize Object: {}", e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.autotune.analyzer.kruizeLayer.KruizeLayer;
import com.autotune.analyzer.kruizeObject.KruizeObject;
import com.autotune.analyzer.kruizeObject.ObjectiveFunction;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.analyzer.performanceProfiles.PerformanceProfilesDeployment;
import com.autotune.analyzer.metricProfiles.MetricProfile;
import com.autotune.analyzer.metricProfiles.MetricProfilesDeployment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -105,11 +105,11 @@ private static ApplicationSearchSpace updateSearchSpace(KruizeExperiment kruizeE
KruizeObject kruizeObject = kruizeExperiment.getAutotuneObject();
String experimentName = kruizeExperiment.getExperimentName();
String experimentId = kruizeObject.getExperiment_id();
PerformanceProfile performanceProfile = PerformanceProfilesDeployment.performanceProfilesMap
.get(kruizeObject.getPerformanceProfile());
ObjectiveFunction objectiveFunction = performanceProfile.getSloInfo().getObjectiveFunction();
MetricProfile metricProfile = MetricProfilesDeployment.metricProfilesMap
.get(kruizeObject.getMetricProfile());
ObjectiveFunction objectiveFunction = metricProfile.getSloInfo().getObjectiveFunction();
String hpoAlgoImpl = kruizeObject.getHpoAlgoImpl();
String direction = performanceProfile.getSloInfo().getDirection();
String direction = metricProfile.getSloInfo().getDirection();
// TODO: Need to add valueType to the ObjectiveFunction!
String valueType = "double";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.autotune.common.trials.ExperimentSummary;
import com.autotune.common.trials.ExperimentTrial;
import com.autotune.common.trials.TrialDetails;
import com.autotune.analyzer.performanceProfiles.PerformanceProfile;
import com.autotune.analyzer.performanceProfiles.PerformanceProfilesDeployment;
import com.autotune.analyzer.metricProfiles.MetricProfile;
import com.autotune.analyzer.metricProfiles.MetricProfilesDeployment;

import java.util.TreeMap;

Expand Down Expand Up @@ -140,9 +140,9 @@ public void summarizeTrial(TrialDetails trialDetails) {
ExperimentTrial bestExperimentTrial = getExperimentTrials().get(bestTrial);
TrialDetails bestTrialDetails = bestExperimentTrial.getTrialDetails().get(TRAINING);
double bestResult = Double.parseDouble(bestTrialDetails.getResult());
PerformanceProfile performanceProfile = PerformanceProfilesDeployment.performanceProfilesMap
.get(kruizeObject.getPerformanceProfile());
String direction = performanceProfile.getSloInfo().getDirection();
MetricProfile metricProfile = MetricProfilesDeployment.metricProfilesMap
.get(kruizeObject.getMetricProfile());
String direction = metricProfile.getSloInfo().getDirection();
if ((direction.equals(MINIMIZE) && currentResult < bestResult) ||
(direction.equals(MAXIMIZE) && currentResult > bestResult)) {
experimentSummary.setBestTrial(currentTrial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public final class KruizeObject {
private SelectorInfo selectorInfo;
private ObjectReference objectReference;
private AnalyzerConstants.ExperimentStatus status;
@SerializedName("performance_profile")
private String performanceProfile;
@SerializedName("metric_profile")
private String metricProfile;
private TrialSettings trial_settings;
private RecommendationSettings recommendation_settings;
private ExperimentUseCaseType experiment_usecase_type;
Expand All @@ -75,7 +75,7 @@ public KruizeObject(String experimentName,
String targetCluster,
String hpoAlgoImpl,
SelectorInfo selectorInfo,
String performanceProfile,
String metricProfile,
String datasource,
ObjectReference objectReference
) throws InvalidValueException {
Expand All @@ -102,7 +102,7 @@ public KruizeObject(String experimentName,
} else {
throw new InvalidValueException(error.toString());
}
this.performanceProfile = performanceProfile;
this.metricProfile = metricProfile;
if (KruizeSupportedTypes.HPO_ALGOS_SUPPORTED.contains(hpoAlgoImpl))
this.hpoAlgoImpl = hpoAlgoImpl;
else
Expand Down Expand Up @@ -205,12 +205,12 @@ public void setStatus(AnalyzerConstants.ExperimentStatus status) {
this.status = status;
}

public String getPerformanceProfile() {
return performanceProfile;
public String getMetricProfile() {
return metricProfile;
}

public void setPerformanceProfile(String performanceProfile) {
this.performanceProfile = performanceProfile;
public void setMetricProfile(String metricProfile) {
this.metricProfile = metricProfile;
}

public TrialSettings getTrial_settings() {
Expand Down Expand Up @@ -315,7 +315,7 @@ public String toString() {
", selectorInfo=" + selectorInfo +
", objectReference=" + objectReference +
", status=" + status +
", performanceProfile='" + performanceProfile + '\'' +
", metricProfile='" + metricProfile + '\'' +
", trial_settings=" + trial_settings +
", recommendation_settings=" + recommendation_settings +
", experimentUseCaseType=" + experiment_usecase_type +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 Red Hat, IBM Corporation and others.
* Copyright (c) 2020, 2024 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.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.autotune.analyzer.performanceProfiles;
package com.autotune.analyzer.metricProfiles;

import com.autotune.analyzer.kruizeObject.SloInfo;
import com.autotune.analyzer.recommendations.term.Terms;
Expand All @@ -22,12 +22,12 @@
import java.util.Map;

/**
* Container class for the PerformanceProfile kubernetes kind, which is used to define
* Container class for the MetricProfile kubernetes kind, which is used to define
* a profile
*
*/

public class PerformanceProfile {
public class MetricProfile {

private String name;

Expand Down Expand Up @@ -61,7 +61,7 @@ public void setSloInfo(SloInfo sloInfo) {
this.sloInfo = sloInfo;
}

public PerformanceProfile(String name, double profile_version, String k8s_type, SloInfo sloInfo) {
public MetricProfile(String name, double profile_version, String k8s_type, SloInfo sloInfo) {
this.name = name;
this.profile_version = profile_version;
this.k8s_type = k8s_type;
Expand Down Expand Up @@ -94,7 +94,7 @@ public void setTerms(Map<String, Terms> terms) {

@Override
public String toString() {
return "PerformanceProfile{" +
return "MetricProfile{" +
"name='" + name + '\'' +
", profile_version=" + profile_version +
", k8s_type='" + k8s_type + '\'' +
Expand Down
Loading
Loading