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

Enable to run Experiment without Goal #1065

Merged
Merged
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
9 changes: 6 additions & 3 deletions pkg/controller.v1alpha3/experiment/util/status_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ func updateTrialsSummary(instance *experimentsv1alpha3.Experiment, trials *trial
sts.RunningTrialList, sts.PendingTrialList, sts.FailedTrialList, sts.SucceededTrialList, sts.KilledTrialList = nil, nil, nil, nil, nil
bestTrialIndex := -1
isObjectiveGoalReached := false
objectiveValueGoal := *instance.Spec.Objective.Goal
var objectiveValueGoal float64
if instance.Spec.Objective.Goal != nil {
objectiveValueGoal = *instance.Spec.Objective.Goal
}
objectiveType := instance.Spec.Objective.Type
objectiveMetricName := instance.Spec.Objective.ObjectiveMetricName

Expand Down Expand Up @@ -90,15 +93,15 @@ func updateTrialsSummary(instance *experimentsv1alpha3.Experiment, trials *trial
bestTrialValue = *objectiveMetricValue
bestTrialIndex = index
}
if bestTrialValue <= objectiveValueGoal {
if instance.Spec.Objective.Goal != nil && bestTrialValue <= objectiveValueGoal {
isObjectiveGoalReached = true
}
} else if objectiveType == commonv1alpha3.ObjectiveTypeMaximize {
if *objectiveMetricValue > bestTrialValue {
bestTrialValue = *objectiveMetricValue
bestTrialIndex = index
}
if bestTrialValue >= objectiveValueGoal {
if instance.Spec.Objective.Goal != nil && bestTrialValue >= objectiveValueGoal {
isObjectiveGoalReached = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,16 @@ func (g *General) ConvertExperiment(e *experimentsv1alpha3.Experiment) *suggesti
},
Objective: &suggestionapi.ObjectiveSpec{
Type: convertObjectiveType(e.Spec.Objective.Type),
Goal: *e.Spec.Objective.Goal,
ObjectiveMetricName: e.Spec.Objective.ObjectiveMetricName,
},
ParameterSpecs: &suggestionapi.ExperimentSpec_ParameterSpecs{
Parameters: convertParameters(e.Spec.Parameters),
},
}
// Set Goal if user defines it in Objective
if e.Spec.Objective.Goal != nil {
res.Spec.Objective.Goal = *e.Spec.Objective.Goal
}
// Set NasConfig if the user defines it in Spec.
if e.Spec.NasConfig != nil {
res.Spec.NasConfig = convertNasConfig(e.Spec.NasConfig)
Expand All @@ -184,7 +187,6 @@ func (g *General) ConvertTrials(ts []trialsv1alpha3.Trial) []*suggestionapi.Tria
Spec: &suggestionapi.TrialSpec{
Objective: &suggestionapi.ObjectiveSpec{
Type: convertObjectiveType(t.Spec.Objective.Type),
Goal: *t.Spec.Objective.Goal,
ObjectiveMetricName: t.Spec.Objective.ObjectiveMetricName,
AdditionalMetricNames: t.Spec.Objective.AdditionalMetricNames,
},
Expand All @@ -198,6 +200,9 @@ func (g *General) ConvertTrials(ts []trialsv1alpha3.Trial) []*suggestionapi.Tria
t.Status.Observation),
},
}
if t.Spec.Objective.Goal != nil {
trial.Spec.Objective.Goal = *t.Spec.Objective.Goal
}
if len(t.Status.Conditions) > 0 {
// We send only the latest condition of the Trial!
trial.Status.Condition = convertTrialConditionType(
Expand Down
9 changes: 6 additions & 3 deletions test/e2e/v1alpha3/resume-e2e-experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,12 @@ func main() {
}

objectiveType := exp.Spec.Objective.Type
goal := *exp.Spec.Objective.Goal
if (objectiveType == commonv1alpha3.ObjectiveTypeMinimize && *metricVal < goal) ||
(objectiveType == commonv1alpha3.ObjectiveTypeMaximize && *metricVal > goal) {
var goal float64
if exp.Spec.Objective.Goal != nil {
goal = *exp.Spec.Objective.Goal
}
if (exp.Spec.Objective.Goal != nil && objectiveType == commonv1alpha3.ObjectiveTypeMinimize && *metricVal < goal) ||
(exp.Spec.Objective.Goal != nil && objectiveType == commonv1alpha3.ObjectiveTypeMaximize && *metricVal > goal) {
log.Print("Objective Goal reached")
} else {

Expand Down
9 changes: 6 additions & 3 deletions test/e2e/v1alpha3/run-e2e-experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ func main() {
}

objectiveType := exp.Spec.Objective.Type
goal := *exp.Spec.Objective.Goal
if (objectiveType == commonv1alpha3.ObjectiveTypeMinimize && *metricVal < goal) ||
(objectiveType == commonv1alpha3.ObjectiveTypeMaximize && *metricVal > goal) {
var goal float64
if exp.Spec.Objective.Goal != nil {
goal = *exp.Spec.Objective.Goal
}
if (exp.Spec.Objective.Goal != nil && objectiveType == commonv1alpha3.ObjectiveTypeMinimize && *metricVal < goal) ||
(exp.Spec.Objective.Goal != nil && objectiveType == commonv1alpha3.ObjectiveTypeMaximize && *metricVal > goal) {
log.Print("Objective Goal reached")
} else {

Expand Down