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

UI: Fix comparison of metric values in Metrics Info Plot #1192

Merged
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
22 changes: 20 additions & 2 deletions pkg/ui/v1alpha3/hp.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,29 @@ func (k *KatibUIHandler) FetchHPJobTrialInfo(w http.ResponseWriter, r *http.Requ
prevMetricTimeValue[m.Metric.Name] = []string{"", ""}

}

newMetricValue, err := strconv.ParseFloat(m.Metric.Value, 64)
if err != nil {
log.Printf("ParseFloat for new metric value: %v failed: %v", m.Metric.Value, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

var prevMetricValue float64
if prevMetricTimeValue[m.Metric.Name][1] != "" {
prevMetricValue, err = strconv.ParseFloat(prevMetricTimeValue[m.Metric.Name][1], 64)
if err != nil {
log.Printf("ParseFloat for prev metric value: %v failed: %v", prevMetricTimeValue[m.Metric.Name][1], err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}

if formatCurrentTime == prevMetricTimeValue[m.Metric.Name][0] &&
((objectiveType == commonv1alpha3.ObjectiveTypeMinimize &&
m.Metric.Value < prevMetricTimeValue[m.Metric.Name][1]) ||
newMetricValue < prevMetricValue) ||
(objectiveType == commonv1alpha3.ObjectiveTypeMaximize &&
m.Metric.Value > prevMetricTimeValue[m.Metric.Name][1])) {
newMetricValue > prevMetricValue)) {

prevMetricTimeValue[m.Metric.Name][1] = m.Metric.Value
for i := len(resultArray) - 1; i >= 0; i-- {
Expand Down