Skip to content

Commit

Permalink
Raise an error for the step parameter
Browse files Browse the repository at this point in the history
Signed-off-by: tenzen-y <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Dec 17, 2022
1 parent 5e9536a commit 09dabf7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/suggestion/v1beta1/internal/search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def convert_to_combinations(search_space):
combinations[parameter.name] = range(int(parameter.min), int(parameter.max)+1, int(parameter.step))
elif parameter.type == DOUBLE:
if parameter.step == "" or parameter.step is None:
return "Param {} step is nil".format(parameter.name)
raise Exception("Param {} step is nil".format(parameter.name))
double_list = np.arange(float(parameter.min), float(parameter.max)+float(parameter.step),
float(parameter.step))
if double_list[-1] > float(parameter.max):
Expand Down
3 changes: 0 additions & 3 deletions pkg/suggestion/v1beta1/optuna/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ def _validate_grid_setting(cls, experiment):

try:
combinations = HyperParameterSearchSpace.convert_to_combinations(search_space)
if isinstance(combinations, str):
return False, combinations

num_combinations = len(list(itertools.product(*combinations.values())))
max_trial_count = experiment.spec.max_trial_count
if max_trial_count > num_combinations:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/v1beta1/suggestion/test_optuna_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_get_suggestion(self, algorithm_name, algorithm_settings):
["algorithm_name", "algorithm_settings", "max_trial_count", "parameters", "result"],
[
# Invalid algorithm name
["invalid", {}, 1, [], grpc.StatusCode.UNKNOWN],
["invalid", {}, 1, [], grpc.StatusCode.INVALID_ARGUMENT],
# [TPE] Valid case
["tpe", {"n_startup_trials": "5", "n_ei_candidates": "24", "random_state": "1"}, 100, [],
Expand Down

0 comments on commit 09dabf7

Please sign in to comment.