Skip to content

Commit

Permalink
review: remove condition to verify algorithmName for early stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
tenzen-y committed Nov 9, 2021
1 parent 543ad58 commit 8ca5b26
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions pkg/controller.v1beta1/suggestion/suggestion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ func (r *ReconcileSuggestion) ReconcileSuggestion(instance *suggestionsv1beta1.S
// If early stopping is used, create RBAC.
// If controller should reconcile RBAC,
// ServiceAccount name must be equal to <suggestion-name>-<suggestion-algorithm>
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" &&
deploy.Spec.Template.Spec.ServiceAccountName == util.GetSuggestionRBACName(instance) {
if instance.Spec.EarlyStopping != nil && deploy.Spec.Template.Spec.ServiceAccountName == util.GetSuggestionRBACName(instance) {

serviceAccount, role, roleBinding, err := r.DesiredRBAC(instance)
if err != nil {
Expand Down Expand Up @@ -275,7 +274,7 @@ func (r *ReconcileSuggestion) ReconcileSuggestion(instance *suggestionsv1beta1.S
// return nil since it is a terminal condition
return nil
}
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" {
if instance.Spec.EarlyStopping != nil {
if err = r.ValidateEarlyStoppingSettings(instance, experiment); err != nil {
logger.Error(err, "Marking suggestion failed as early stopping settings validation failed")
msg := fmt.Sprintf("Validation failed: %v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (g *General) SyncAssignments(

earlyStoppingRules := []commonapiv1beta1.EarlyStoppingRule{}
// If early stopping is set, call GetEarlyStoppingRules after GetSuggestions.
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" {
if instance.Spec.EarlyStopping != nil {
endpoint = util.GetEarlyStoppingEndpoint(instance)
connEarlyStopping, err := grpc.Dial(endpoint, grpc.WithInsecure())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/earlystopping/v1beta1/medianstop/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def validate_medianstop_setting(early_stopping_settings):
for setting in early_stopping_settings:
try:
if setting.name == "min_trials_required":
if not (int(setting.value) >= 0):
if not (int(setting.value) > 0):
return False, "min_trials_required must be greater or equal than zero (>=0)"
elif setting.name == "start_step":
if not (int(setting.value) >= 1):
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1beta1/earlystopping/test_medianstop_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_validate_early_stopping_settings(self):
algorithm_settings=[
api_pb2.EarlyStoppingSetting(
name="min_trials_required",
value="-1",
value="0",
),
],
)
Expand Down

0 comments on commit 8ca5b26

Please sign in to comment.