Skip to content

Commit cae15c6

Browse files
committed
review: remove condition to verify algorithmName for early stopping
1 parent 543ad58 commit cae15c6

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

pkg/controller.v1beta1/suggestion/suggestion_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,7 @@ func (r *ReconcileSuggestion) ReconcileSuggestion(instance *suggestionsv1beta1.S
223223
// If early stopping is used, create RBAC.
224224
// If controller should reconcile RBAC,
225225
// ServiceAccount name must be equal to <suggestion-name>-<suggestion-algorithm>
226-
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" &&
227-
deploy.Spec.Template.Spec.ServiceAccountName == util.GetSuggestionRBACName(instance) {
226+
if instance.Spec.EarlyStopping != nil && deploy.Spec.Template.Spec.ServiceAccountName == util.GetSuggestionRBACName(instance) {
228227

229228
serviceAccount, role, roleBinding, err := r.DesiredRBAC(instance)
230229
if err != nil {
@@ -275,7 +274,7 @@ func (r *ReconcileSuggestion) ReconcileSuggestion(instance *suggestionsv1beta1.S
275274
// return nil since it is a terminal condition
276275
return nil
277276
}
278-
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" {
277+
if instance.Spec.EarlyStopping != nil {
279278
if err = r.ValidateEarlyStoppingSettings(instance, experiment); err != nil {
280279
logger.Error(err, "Marking suggestion failed as early stopping settings validation failed")
281280
msg := fmt.Sprintf("Validation failed: %v", err)

pkg/controller.v1beta1/suggestion/suggestionclient/suggestionclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (g *General) SyncAssignments(
130130

131131
earlyStoppingRules := []commonapiv1beta1.EarlyStoppingRule{}
132132
// If early stopping is set, call GetEarlyStoppingRules after GetSuggestions.
133-
if instance.Spec.EarlyStopping != nil && instance.Spec.EarlyStopping.AlgorithmName != "" {
133+
if instance.Spec.EarlyStopping != nil {
134134
endpoint = util.GetEarlyStoppingEndpoint(instance)
135135
connEarlyStopping, err := grpc.Dial(endpoint, grpc.WithInsecure())
136136
if err != nil {

pkg/earlystopping/v1beta1/medianstop/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def validate_medianstop_setting(early_stopping_settings):
8484
for setting in early_stopping_settings:
8585
try:
8686
if setting.name == "min_trials_required":
87-
if not (int(setting.value) >= 0):
88-
return False, "min_trials_required must be greater or equal than zero (>=0)"
87+
if not (int(setting.value) > 0):
88+
return False, "min_trials_required must be greater than zero (>0)"
8989
elif setting.name == "start_step":
9090
if not (int(setting.value) >= 1):
9191
return False, "start_step must be greater or equal than one (>=1)"

test/unit/v1beta1/earlystopping/test_medianstop_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ def test_validate_early_stopping_settings(self):
8787
algorithm_settings=[
8888
api_pb2.EarlyStoppingSetting(
8989
name="min_trials_required",
90-
value="-1",
90+
value="0",
9191
),
9292
],
9393
)
9494

9595
_, _, code, details = utils.call_validate(self.test_server, early_stopping)
9696
self.assertEqual(code, grpc.StatusCode.INVALID_ARGUMENT)
97-
self.assertEqual(details, "min_trials_required must be greater or equal than zero (>=0)")
97+
self.assertEqual(details, "min_trials_required must be greater than zero (>0)")
9898

9999
# Wrong start_step
100100
early_stopping = api_pb2.EarlyStoppingSpec(

0 commit comments

Comments
 (0)