Skip to content

Commit

Permalink
feat(api): Add total number of trials
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege committed May 16, 2019
1 parent 3cbb565 commit b04d551
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ExperimentSpec struct {
// Whether to retain historical data in DB after deletion.
RetainHistoricalData bool `json:"retainHistoricalData,omitempty"`

// For v1alpha2 we will keep the metrics collector implementation same as v1alpha1.
// For v1alpha2 we will keep the metrics collector implementation same as v1alpha1.
MetricsCollectorSpec *MetricsCollectorSpec `json:"metricsCollectorSpec,omitempty"`

NasConfig *NasConfig `json:"nasConfig,omitempty"`
Expand Down Expand Up @@ -79,6 +79,9 @@ type ExperimentStatus struct {
// Current optimal trial parameters and observations.
CurrentOptimalTrial OptimalTrial `json:"currentOptimalTrial,omitempty"`

// Trials is the total number of trials owned by the experiment.
Trials int `json:"trials,omitempty"`

// How many trials have succeeded.
TrialsSucceeded int `json:"trialsSucceeded,omitempty"`

Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/v1alpha2/experiment/util/status_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func UpdateExperimentStatus(instance *experimentsv1alpha2.Experiment, trials *tr

func updateTrialsSummary(instance *experimentsv1alpha2.Experiment, trials *trialsv1alpha2.TrialList) bool {

var trialsPending, trialsRunning, trialsSucceeded, trialsFailed, trialsKilled int
var totalTrials, trialsPending, trialsRunning, trialsSucceeded, trialsFailed, trialsKilled int
var bestTrialValue float64
bestTrialIndex := -1
isObjectiveGoalReached := false
Expand All @@ -53,6 +53,7 @@ func updateTrialsSummary(instance *experimentsv1alpha2.Experiment, trials *trial
objectiveMetricName := instance.Spec.Objective.ObjectiveMetricName

for index, trial := range trials.Items {
totalTrials++
if trial.IsKilled() {
trialsKilled++
} else if trial.IsFailed() {
Expand Down Expand Up @@ -95,6 +96,8 @@ func updateTrialsSummary(instance *experimentsv1alpha2.Experiment, trials *trial
}
}
}

instance.Status.Trials = totalTrials
instance.Status.TrialsPending = trialsPending
instance.Status.TrialsRunning = trialsRunning
instance.Status.TrialsSucceeded = trialsSucceeded
Expand Down

0 comments on commit b04d551

Please sign in to comment.