Skip to content

Commit

Permalink
fix: Use 64 instead of 32 since we are using float64 (#883)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege authored and k8s-ci-robot committed Oct 15, 2019
1 parent bad9626 commit 8c8094a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions pkg/controller.v1alpha3/experiment/experiment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (r *ReconcileExperiment) Reconcile(request reconcile.Request) (reconcile.Re
return reconcile.Result{}, nil
}

// ReconcileExperiment is the main reconcile loop.
func (r *ReconcileExperiment) ReconcileExperiment(instance *experimentsv1alpha3.Experiment) error {
logger := log.WithValues("Experiment", types.NamespacedName{Name: instance.GetName(), Namespace: instance.GetNamespace()})
trials := &trialsv1alpha3.TrialList{}
Expand All @@ -246,6 +247,7 @@ func (r *ReconcileExperiment) ReconcileExperiment(instance *experimentsv1alpha3.
return nil
}

// ReconcileTrials syncs trials.
func (r *ReconcileExperiment) ReconcileTrials(instance *experimentsv1alpha3.Experiment, trials []trialsv1alpha3.Trial) error {

logger := log.WithValues("Experiment", types.NamespacedName{Name: instance.GetName(), Namespace: instance.GetNamespace()})
Expand Down Expand Up @@ -283,6 +285,13 @@ func (r *ReconcileExperiment) ReconcileTrials(instance *experimentsv1alpha3.Expe
addCount = 0
}

logger.Info("Statistics",
"requiredActiveCount", requiredActiveCount,
"parallelCount", parallelCount,
"activeCount", activeCount,
"completedCount", completedCount,
)

//skip if no trials need to be created
if addCount > 0 {
//create "addCount" number of trials
Expand Down Expand Up @@ -336,6 +345,7 @@ func (r *ReconcileExperiment) deleteTrials(instance *experimentsv1alpha3.Experim
return nil
}

// ReconcileSuggestions gets or creates the suggestion if needed.
func (r *ReconcileExperiment) ReconcileSuggestions(instance *experimentsv1alpha3.Experiment, currentCount, addCount int32) ([]suggestionsv1alpha3.TrialAssignment, error) {
logger := log.WithValues("Experiment", types.NamespacedName{Name: instance.GetName(), Namespace: instance.GetNamespace()})
var assignments []suggestionsv1alpha3.TrialAssignment
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller.v1alpha3/trial/trial_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func getBestObjectiveMetricValue(metricLogs []*api_pb.MetricLog, objectiveType c
return nil
}

bestObjectiveValue, _ := strconv.ParseFloat(metricLogs[0].Metric.Value, 32)
bestObjectiveValue, _ := strconv.ParseFloat(metricLogs[0].Metric.Value, 64)
for _, metricLog := range metricLogs[1:] {
objectiveMetricValue, _ := strconv.ParseFloat(metricLog.Metric.Value, 32)
objectiveMetricValue, _ := strconv.ParseFloat(metricLog.Metric.Value, 64)
if objectiveType == commonv1alpha3.ObjectiveTypeMinimize {
if objectiveMetricValue < bestObjectiveValue {
bestObjectiveValue = objectiveMetricValue
Expand Down

0 comments on commit 8c8094a

Please sign in to comment.