From 116f9f0fcd37ae78fe36936560dde034296d9e2a Mon Sep 17 00:00:00 2001 From: Andrey Velichkevich Date: Sun, 26 Apr 2020 03:45:29 +0100 Subject: [PATCH] Refactor suggestion services folder structure (#1166) * Refactor suggestion services folder structure * Move base health service to internal * Rename service and base service files --- cmd/suggestion/chocolate/v1alpha3/main.py | 2 +- cmd/suggestion/hyperband/v1alpha3/main.py | 2 +- cmd/suggestion/hyperopt/v1alpha3/main.py | 2 +- cmd/suggestion/nas/enas/v1alpha3/main.py | 2 +- cmd/suggestion/skopt/v1alpha3/main.py | 2 +- docs/new-algorithm-service.md | 4 +-- pkg/suggestion/test_requirements.txt | 5 ---- .../{ => bayesianoptimization}/__init__.py | 0 .../{src => }/acquisition_func.py | 0 .../{src => }/algorithm_manager.py | 2 +- .../bayesian_optimization_algorithm.py | 4 +-- .../{src => }/global_optimizer.py | 8 ++--- .../{src => model}/__init__.py | 0 .../{src => }/model/gp.py | 0 .../{src => }/model/rf.py | 0 .../bayesianoptimization/{src => }/utils.py | 0 .../src/model => chocolate}/__init__.py | 0 ...e_chocolate_service.py => base_service.py} | 0 .../service.py} | 6 ++-- pkg/suggestion/v1alpha3/hyperband/__init__.py | 0 .../v1alpha3/{ => hyperband}/parameter.py | 0 .../v1alpha3/{ => hyperband}/parsing_util.py | 2 +- .../service.py} | 30 +++++++++---------- pkg/suggestion/v1alpha3/hyperopt/__init__.py | 0 ...se_hyperopt_service.py => base_service.py} | 6 ++-- .../service.py} | 4 +-- .../{ => internal}/base_health_service.py | 0 .../v1alpha3/internal/search_space.py | 2 +- pkg/suggestion/v1alpha3/nas/enas/__init__.py | 0 .../nas/{enas_service.py => enas/service.py} | 2 +- pkg/suggestion/v1alpha3/skopt/__init__.py | 0 ...{base_skopt_service.py => base_service.py} | 2 +- .../{skopt_service.py => skopt/service.py} | 4 +-- .../v1alpha3/test_chocolate_service.py.failed | 2 +- test/suggestion/v1alpha3/test_enas_service.py | 2 +- .../v1alpha3/test_hyperband_service.py | 2 +- .../v1alpha3/test_hyperopt_service.py | 2 +- .../suggestion/v1alpha3/test_skopt_service.py | 2 +- 38 files changed, 47 insertions(+), 54 deletions(-) delete mode 100644 pkg/suggestion/test_requirements.txt rename pkg/suggestion/v1alpha3/{ => bayesianoptimization}/__init__.py (100%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/acquisition_func.py (100%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/algorithm_manager.py (98%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/bayesian_optimization_algorithm.py (94%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/global_optimizer.py (96%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => model}/__init__.py (100%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/model/gp.py (100%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/model/rf.py (100%) rename pkg/suggestion/v1alpha3/bayesianoptimization/{src => }/utils.py (100%) rename pkg/suggestion/v1alpha3/{bayesianoptimization/src/model => chocolate}/__init__.py (100%) rename pkg/suggestion/v1alpha3/chocolate/{base_chocolate_service.py => base_service.py} (100%) rename pkg/suggestion/v1alpha3/{chocolate_service.py => chocolate/service.py} (90%) create mode 100644 pkg/suggestion/v1alpha3/hyperband/__init__.py rename pkg/suggestion/v1alpha3/{ => hyperband}/parameter.py (100%) rename pkg/suggestion/v1alpha3/{ => hyperband}/parsing_util.py (98%) rename pkg/suggestion/v1alpha3/{hyperband_service.py => hyperband/service.py} (91%) create mode 100644 pkg/suggestion/v1alpha3/hyperopt/__init__.py rename pkg/suggestion/v1alpha3/hyperopt/{base_hyperopt_service.py => base_service.py} (98%) rename pkg/suggestion/v1alpha3/{hyperopt_service.py => hyperopt/service.py} (92%) rename pkg/suggestion/v1alpha3/{ => internal}/base_health_service.py (100%) create mode 100644 pkg/suggestion/v1alpha3/nas/enas/__init__.py rename pkg/suggestion/v1alpha3/nas/{enas_service.py => enas/service.py} (99%) create mode 100644 pkg/suggestion/v1alpha3/skopt/__init__.py rename pkg/suggestion/v1alpha3/skopt/{base_skopt_service.py => base_service.py} (98%) rename pkg/suggestion/v1alpha3/{skopt_service.py => skopt/service.py} (94%) diff --git a/cmd/suggestion/chocolate/v1alpha3/main.py b/cmd/suggestion/chocolate/v1alpha3/main.py index e2a5db7dad2..106c81c7dc7 100644 --- a/cmd/suggestion/chocolate/v1alpha3/main.py +++ b/cmd/suggestion/chocolate/v1alpha3/main.py @@ -2,7 +2,7 @@ import time from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.health.python import health_pb2_grpc -from pkg.suggestion.v1alpha3.chocolate_service import ChocolateService +from pkg.suggestion.v1alpha3.chocolate.service import ChocolateService from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/cmd/suggestion/hyperband/v1alpha3/main.py b/cmd/suggestion/hyperband/v1alpha3/main.py index e9ad4aebc1a..bd98a1b9f41 100644 --- a/cmd/suggestion/hyperband/v1alpha3/main.py +++ b/cmd/suggestion/hyperband/v1alpha3/main.py @@ -2,7 +2,7 @@ import time from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.health.python import health_pb2_grpc -from pkg.suggestion.v1alpha3.hyperband_service import HyperbandService +from pkg.suggestion.v1alpha3.hyperband.service import HyperbandService from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/cmd/suggestion/hyperopt/v1alpha3/main.py b/cmd/suggestion/hyperopt/v1alpha3/main.py index ac92736e1e0..b32f8cbbee1 100644 --- a/cmd/suggestion/hyperopt/v1alpha3/main.py +++ b/cmd/suggestion/hyperopt/v1alpha3/main.py @@ -2,7 +2,7 @@ import time from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.health.python import health_pb2_grpc -from pkg.suggestion.v1alpha3.hyperopt_service import HyperoptService +from pkg.suggestion.v1alpha3.hyperopt.service import HyperoptService from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/cmd/suggestion/nas/enas/v1alpha3/main.py b/cmd/suggestion/nas/enas/v1alpha3/main.py index 402dfd8f10c..aa1d03173fd 100644 --- a/cmd/suggestion/nas/enas/v1alpha3/main.py +++ b/cmd/suggestion/nas/enas/v1alpha3/main.py @@ -4,7 +4,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.health.python import health_pb2_grpc -from pkg.suggestion.v1alpha3.nas.enas_service import EnasService +from pkg.suggestion.v1alpha3.nas.enas.service import EnasService _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/cmd/suggestion/skopt/v1alpha3/main.py b/cmd/suggestion/skopt/v1alpha3/main.py index 48ca7d16e60..3b8c6e8c7d3 100644 --- a/cmd/suggestion/skopt/v1alpha3/main.py +++ b/cmd/suggestion/skopt/v1alpha3/main.py @@ -2,7 +2,7 @@ import time from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.health.python import health_pb2_grpc -from pkg.suggestion.v1alpha3.skopt_service import SkoptService +from pkg.suggestion.v1alpha3.skopt.service import SkoptService from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/docs/new-algorithm-service.md b/docs/new-algorithm-service.md index c047283bea4..e1d10a6ff7f 100644 --- a/docs/new-algorithm-service.md +++ b/docs/new-algorithm-service.md @@ -17,7 +17,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2 from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.suggestion.v1alpha3.internal.search_space import HyperParameter, HyperParameterSearchSpace from pkg.suggestion.v1alpha3.internal.trial import Trial, Assignment -from pkg.suggestion.v1alpha3.hyperopt.base_hyperopt_service import BaseHyperoptService +from pkg.suggestion.v1alpha3.hyperopt.base_service import BaseHyperoptService from pkg.suggestion.v1alpha3.base_health_service import HealthServicer @@ -122,7 +122,7 @@ import unittest from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.hyperopt_service import HyperoptService +from pkg.suggestion.v1alpha3.hyperopt.service import HyperoptService class TestHyperopt(unittest.TestCase): def setUp(self): diff --git a/pkg/suggestion/test_requirements.txt b/pkg/suggestion/test_requirements.txt deleted file mode 100644 index 69022052405..00000000000 --- a/pkg/suggestion/test_requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -pylint -pytest -pytest-cov -pyyaml -python-box diff --git a/pkg/suggestion/v1alpha3/__init__.py b/pkg/suggestion/v1alpha3/bayesianoptimization/__init__.py similarity index 100% rename from pkg/suggestion/v1alpha3/__init__.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/__init__.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/acquisition_func.py b/pkg/suggestion/v1alpha3/bayesianoptimization/acquisition_func.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/acquisition_func.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/acquisition_func.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/algorithm_manager.py b/pkg/suggestion/v1alpha3/bayesianoptimization/algorithm_manager.py similarity index 98% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/algorithm_manager.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/algorithm_manager.py index 9bf151a562c..0b00d88819d 100644 --- a/pkg/suggestion/v1alpha3/bayesianoptimization/src/algorithm_manager.py +++ b/pkg/suggestion/v1alpha3/bayesianoptimization/algorithm_manager.py @@ -3,7 +3,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2 -from .utils import get_logger +from pkg.suggestion.v1alpha3.bayesianoptimization.utils import get_logger def deal_with_discrete(feasible_values, current_value): diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/bayesian_optimization_algorithm.py b/pkg/suggestion/v1alpha3/bayesianoptimization/bayesian_optimization_algorithm.py similarity index 94% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/bayesian_optimization_algorithm.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/bayesian_optimization_algorithm.py index ce207e91765..fb6d906a7d1 100644 --- a/pkg/suggestion/v1alpha3/bayesianoptimization/src/bayesian_optimization_algorithm.py +++ b/pkg/suggestion/v1alpha3/bayesianoptimization/bayesian_optimization_algorithm.py @@ -2,7 +2,7 @@ import numpy as np from sklearn.preprocessing import MinMaxScaler -from .global_optimizer import GlobalOptimizer +from pkg.suggestion.v1alpha3.bayesianoptimization.global_optimizer import GlobalOptimizer class BOAlgorithm: @@ -31,7 +31,7 @@ def __init__(self, experiment_name, dim, N, lowerbound, upperbound, X_train, y_t else: self.current_optimal = max(self.y_train) self.logger.debug("create optimizer", extra={ - "Experiment": self._experiment_name}) + "Experiment": self._experiment_name}) # initialize the global optimizer self.optimizer = GlobalOptimizer( N, diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/global_optimizer.py b/pkg/suggestion/v1alpha3/bayesianoptimization/global_optimizer.py similarity index 96% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/global_optimizer.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/global_optimizer.py index acd9138b610..080404d1f0e 100644 --- a/pkg/suggestion/v1alpha3/bayesianoptimization/src/global_optimizer.py +++ b/pkg/suggestion/v1alpha3/bayesianoptimization/global_optimizer.py @@ -5,10 +5,10 @@ import numpy as np -from .acquisition_func import AcquisitionFunc -from .model.gp import GaussianProcessModel -from .model.rf import RandomForestModel -from .utils import get_logger +from pkg.suggestion.v1alpha3.bayesianoptimization.acquisition_func import AcquisitionFunc +from pkg.suggestion.v1alpha3.bayesianoptimization.model.gp import GaussianProcessModel +from pkg.suggestion.v1alpha3.bayesianoptimization.model.rf import RandomForestModel +from pkg.suggestion.v1alpha3.bayesianoptimization.utils import get_logger class RectPack: diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/__init__.py b/pkg/suggestion/v1alpha3/bayesianoptimization/model/__init__.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/__init__.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/model/__init__.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/model/gp.py b/pkg/suggestion/v1alpha3/bayesianoptimization/model/gp.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/model/gp.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/model/gp.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/model/rf.py b/pkg/suggestion/v1alpha3/bayesianoptimization/model/rf.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/model/rf.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/model/rf.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/utils.py b/pkg/suggestion/v1alpha3/bayesianoptimization/utils.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/utils.py rename to pkg/suggestion/v1alpha3/bayesianoptimization/utils.py diff --git a/pkg/suggestion/v1alpha3/bayesianoptimization/src/model/__init__.py b/pkg/suggestion/v1alpha3/chocolate/__init__.py similarity index 100% rename from pkg/suggestion/v1alpha3/bayesianoptimization/src/model/__init__.py rename to pkg/suggestion/v1alpha3/chocolate/__init__.py diff --git a/pkg/suggestion/v1alpha3/chocolate/base_chocolate_service.py b/pkg/suggestion/v1alpha3/chocolate/base_service.py similarity index 100% rename from pkg/suggestion/v1alpha3/chocolate/base_chocolate_service.py rename to pkg/suggestion/v1alpha3/chocolate/base_service.py diff --git a/pkg/suggestion/v1alpha3/chocolate_service.py b/pkg/suggestion/v1alpha3/chocolate/service.py similarity index 90% rename from pkg/suggestion/v1alpha3/chocolate_service.py rename to pkg/suggestion/v1alpha3/chocolate/service.py index 1662c9ac84f..2afee5b74d0 100644 --- a/pkg/suggestion/v1alpha3/chocolate_service.py +++ b/pkg/suggestion/v1alpha3/chocolate/service.py @@ -4,11 +4,11 @@ from pkg.apis.manager.v1alpha3.python import api_pb2 from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3.internal.constant import * +from pkg.suggestion.v1alpha3.internal.constant import DOUBLE from pkg.suggestion.v1alpha3.internal.search_space import HyperParameterSearchSpace from pkg.suggestion.v1alpha3.internal.trial import Trial, Assignment -from pkg.suggestion.v1alpha3.chocolate.base_chocolate_service import BaseChocolateService -from pkg.suggestion.v1alpha3.base_health_service import HealthServicer +from pkg.suggestion.v1alpha3.chocolate.base_service import BaseChocolateService +from pkg.suggestion.v1alpha3.internal.base_health_service import HealthServicer logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1alpha3/hyperband/__init__.py b/pkg/suggestion/v1alpha3/hyperband/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/pkg/suggestion/v1alpha3/parameter.py b/pkg/suggestion/v1alpha3/hyperband/parameter.py similarity index 100% rename from pkg/suggestion/v1alpha3/parameter.py rename to pkg/suggestion/v1alpha3/hyperband/parameter.py diff --git a/pkg/suggestion/v1alpha3/parsing_util.py b/pkg/suggestion/v1alpha3/hyperband/parsing_util.py similarity index 98% rename from pkg/suggestion/v1alpha3/parsing_util.py rename to pkg/suggestion/v1alpha3/hyperband/parsing_util.py index a9bec7cd32e..f054a882f71 100644 --- a/pkg/suggestion/v1alpha3/parsing_util.py +++ b/pkg/suggestion/v1alpha3/hyperband/parsing_util.py @@ -6,7 +6,7 @@ from collections.abc import Iterable from pkg.apis.manager.v1alpha3.python import api_pb2 import numpy as np -from .parameter import ParameterConfig +from pkg.suggestion.v1alpha3.hyperband.parameter import ParameterConfig def _deal_with_discrete(feasible_values, current_value): diff --git a/pkg/suggestion/v1alpha3/hyperband_service.py b/pkg/suggestion/v1alpha3/hyperband/service.py similarity index 91% rename from pkg/suggestion/v1alpha3/hyperband_service.py rename to pkg/suggestion/v1alpha3/hyperband/service.py index d508687c3de..280eb78b9df 100644 --- a/pkg/suggestion/v1alpha3/hyperband_service.py +++ b/pkg/suggestion/v1alpha3/hyperband/service.py @@ -6,8 +6,8 @@ from pkg.apis.manager.v1alpha3.python import api_pb2 from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3 import parsing_util -from pkg.suggestion.v1alpha3.base_health_service import HealthServicer +from pkg.suggestion.v1alpha3.hyperband import parsing_util +from pkg.suggestion.v1alpha3.internal.base_health_service import HealthServicer logger = getLogger(__name__) FORMAT = '%(asctime)-15s Experiment %(experiment_name)s %(message)s' @@ -43,7 +43,7 @@ def GetSuggestions(self, request, context): return reply except Exception as e: logger.error("Fail to generate trials: \n%s", - traceback.format_exc(), extra={"experiment_name": experiment.name}) + traceback.format_exc(), extra={"experiment_name": experiment.name}) raise e def _update_hbParameters(self, param): @@ -72,25 +72,25 @@ def _make_bracket(self, experiment, param): param.evaluating_trials = 0 logger.info("HyperBand Param eta %d.", - param.eta, extra={"experiment_name": experiment.name}) + param.eta, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param R %d.", - param.r_l, extra={"experiment_name": experiment.name}) + param.r_l, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param sMax %d.", - param.s_max, extra={"experiment_name": experiment.name}) + param.s_max, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param B %d.", - param.b_l, extra={"experiment_name": experiment.name}) + param.b_l, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param n %d.", - param.n, extra={"experiment_name": experiment.name}) + param.n, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param r %d.", - param.r, extra={"experiment_name": experiment.name}) + param.r, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param s %d.", - param.current_s, extra={"experiment_name": experiment.name}) + param.current_s, extra={"experiment_name": experiment.name}) logger.info("HyperBand Param i %d.", - param.current_i, extra={"experiment_name": experiment.name}) + param.current_i, extra={"experiment_name": experiment.name}) logger.info("HyperBand evaluating trials count %d.", - param.evaluating_trials, extra={"experiment_name": experiment.name}) + param.evaluating_trials, extra={"experiment_name": experiment.name}) logger.info("HyperBand budget resource name %s.", - param.resource_name, extra={"experiment_name": experiment.name}) + param.resource_name, extra={"experiment_name": experiment.name}) if param.evaluating_trials == 0: self._new_hbParameters(param) @@ -107,7 +107,7 @@ def _make_child_bracket(self, experiment, param): last_trials, r_i, param.resource_name) logger.info("Generate %d trials by child bracket.", - top_trials_num, extra={"experiment_name": experiment.name}) + top_trials_num, extra={"experiment_name": experiment.name}) return trialSpecs def _get_last_trials(self, all_trials, latest_trials_num): @@ -180,7 +180,7 @@ def _make_master_bracket(self, experiment, param): value=str(hp['value'])) trial_specs.append(trial_spec) logger.info("Generate %d trials by master bracket.", - n, extra={"experiment_name": experiment.name}) + n, extra={"experiment_name": experiment.name}) return trial_specs def _set_validate_context_error(self, context, error_message): diff --git a/pkg/suggestion/v1alpha3/hyperopt/__init__.py b/pkg/suggestion/v1alpha3/hyperopt/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/pkg/suggestion/v1alpha3/hyperopt/base_hyperopt_service.py b/pkg/suggestion/v1alpha3/hyperopt/base_service.py similarity index 98% rename from pkg/suggestion/v1alpha3/hyperopt/base_hyperopt_service.py rename to pkg/suggestion/v1alpha3/hyperopt/base_service.py index 68f63903843..ef21b0cc958 100644 --- a/pkg/suggestion/v1alpha3/hyperopt/base_hyperopt_service.py +++ b/pkg/suggestion/v1alpha3/hyperopt/base_service.py @@ -2,7 +2,7 @@ import numpy as np import logging -from pkg.suggestion.v1alpha3.internal.constant import * +from pkg.suggestion.v1alpha3.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL from pkg.suggestion.v1alpha3.internal.trial import Assignment logger = logging.getLogger(__name__) @@ -72,14 +72,13 @@ def getSuggestions(self, trials, request_number): recorded_trials_names = self.fmin.trials.specs - hyperopt_trial_new_ids = [] hyperopt_trial_specs = [] hyperopt_trial_results = [] hyperopt_trial_miscs = [] # Update hyperopt FMin with new completed Trials for trial in trials: - if {"trial-name":trial.name} not in recorded_trials_names: + if {"trial-name": trial.name} not in recorded_trials_names: # Produce new id for the new Trial new_id = self.fmin.trials.new_trial_ids(1) hyperopt_trial_new_ids.append(new_id[0]) @@ -107,7 +106,6 @@ def getSuggestions(self, trials, request_number): hyperopt_trial_miscs_idxs[param.name] = new_id hyperopt_trial_miscs_vals[param.name] = [index_of_value_in_list] - hyperopt_trial_misc["idxs"] = hyperopt_trial_miscs_idxs hyperopt_trial_misc["vals"] = hyperopt_trial_miscs_vals hyperopt_trial_miscs.append(hyperopt_trial_misc) diff --git a/pkg/suggestion/v1alpha3/hyperopt_service.py b/pkg/suggestion/v1alpha3/hyperopt/service.py similarity index 92% rename from pkg/suggestion/v1alpha3/hyperopt_service.py rename to pkg/suggestion/v1alpha3/hyperopt/service.py index 0a4cba9f856..44bcc3f4e94 100644 --- a/pkg/suggestion/v1alpha3/hyperopt_service.py +++ b/pkg/suggestion/v1alpha3/hyperopt/service.py @@ -5,8 +5,8 @@ from pkg.suggestion.v1alpha3.internal.search_space import HyperParameterSearchSpace from pkg.suggestion.v1alpha3.internal.trial import Trial, Assignment -from pkg.suggestion.v1alpha3.hyperopt.base_hyperopt_service import BaseHyperoptService -from pkg.suggestion.v1alpha3.base_health_service import HealthServicer +from pkg.suggestion.v1alpha3.hyperopt.base_service import BaseHyperoptService +from pkg.suggestion.v1alpha3.internal.base_health_service import HealthServicer logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1alpha3/base_health_service.py b/pkg/suggestion/v1alpha3/internal/base_health_service.py similarity index 100% rename from pkg/suggestion/v1alpha3/base_health_service.py rename to pkg/suggestion/v1alpha3/internal/base_health_service.py diff --git a/pkg/suggestion/v1alpha3/internal/search_space.py b/pkg/suggestion/v1alpha3/internal/search_space.py index f061bec8c8d..0f2d694c021 100644 --- a/pkg/suggestion/v1alpha3/internal/search_space.py +++ b/pkg/suggestion/v1alpha3/internal/search_space.py @@ -1,7 +1,7 @@ import logging from pkg.apis.manager.v1alpha3.python import api_pb2 as api -from .constant import * +from pkg.suggestion.v1alpha3.internal.constant import * logging.basicConfig(level=logging.DEBUG) diff --git a/pkg/suggestion/v1alpha3/nas/enas/__init__.py b/pkg/suggestion/v1alpha3/nas/enas/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/pkg/suggestion/v1alpha3/nas/enas_service.py b/pkg/suggestion/v1alpha3/nas/enas/service.py similarity index 99% rename from pkg/suggestion/v1alpha3/nas/enas_service.py rename to pkg/suggestion/v1alpha3/nas/enas/service.py index 0419610c41b..6874d0ff03c 100644 --- a/pkg/suggestion/v1alpha3/nas/enas_service.py +++ b/pkg/suggestion/v1alpha3/nas/enas/service.py @@ -11,7 +11,7 @@ from pkg.suggestion.v1alpha3.nas.enas.Operation import SearchSpace from pkg.suggestion.v1alpha3.nas.enas.AlgorithmSettings import ( parseAlgorithmSettings, algorithmSettingsValidator, enableNoneSettingsList) -from pkg.suggestion.v1alpha3.base_health_service import HealthServicer +from pkg.suggestion.v1alpha3.internal.base_health_service import HealthServicer class EnasExperiment: diff --git a/pkg/suggestion/v1alpha3/skopt/__init__.py b/pkg/suggestion/v1alpha3/skopt/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py b/pkg/suggestion/v1alpha3/skopt/base_service.py similarity index 98% rename from pkg/suggestion/v1alpha3/skopt/base_skopt_service.py rename to pkg/suggestion/v1alpha3/skopt/base_service.py index 8ef5a4ece8c..29f0c57cd2b 100644 --- a/pkg/suggestion/v1alpha3/skopt/base_skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/base_service.py @@ -2,7 +2,7 @@ import logging import skopt -from pkg.suggestion.v1alpha3.internal.constant import * +from pkg.suggestion.v1alpha3.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL from pkg.suggestion.v1alpha3.internal.trial import Assignment logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1alpha3/skopt_service.py b/pkg/suggestion/v1alpha3/skopt/service.py similarity index 94% rename from pkg/suggestion/v1alpha3/skopt_service.py rename to pkg/suggestion/v1alpha3/skopt/service.py index 341ad8f5200..edc3a24bc68 100644 --- a/pkg/suggestion/v1alpha3/skopt_service.py +++ b/pkg/suggestion/v1alpha3/skopt/service.py @@ -4,8 +4,8 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.suggestion.v1alpha3.internal.search_space import HyperParameterSearchSpace from pkg.suggestion.v1alpha3.internal.trial import Trial, Assignment -from pkg.suggestion.v1alpha3.skopt.base_skopt_service import BaseSkoptService -from pkg.suggestion.v1alpha3.base_health_service import HealthServicer +from pkg.suggestion.v1alpha3.skopt.base_service import BaseSkoptService +from pkg.suggestion.v1alpha3.internal.base_health_service import HealthServicer logger = logging.getLogger(__name__) diff --git a/test/suggestion/v1alpha3/test_chocolate_service.py.failed b/test/suggestion/v1alpha3/test_chocolate_service.py.failed index a229ef577cb..622f00b55bf 100644 --- a/test/suggestion/v1alpha3/test_chocolate_service.py.failed +++ b/test/suggestion/v1alpha3/test_chocolate_service.py.failed @@ -5,7 +5,7 @@ import unittest from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.chocolate_service import ChocolateService +from pkg.suggestion.v1alpha3.chocolate.service import ChocolateService class TestHyperopt(unittest.TestCase): diff --git a/test/suggestion/v1alpha3/test_enas_service.py b/test/suggestion/v1alpha3/test_enas_service.py index 2474f73ee93..9460fe0fb9f 100644 --- a/test/suggestion/v1alpha3/test_enas_service.py +++ b/test/suggestion/v1alpha3/test_enas_service.py @@ -5,7 +5,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.nas.enas_service import EnasService +from pkg.suggestion.v1alpha3.nas.enas.service import EnasService class TestEnas(unittest.TestCase): diff --git a/test/suggestion/v1alpha3/test_hyperband_service.py b/test/suggestion/v1alpha3/test_hyperband_service.py index cdc811bc8af..3627ceb06f9 100644 --- a/test/suggestion/v1alpha3/test_hyperband_service.py +++ b/test/suggestion/v1alpha3/test_hyperband_service.py @@ -5,7 +5,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.hyperband_service import HyperbandService +from pkg.suggestion.v1alpha3.hyperband.service import HyperbandService class TestHyperband(unittest.TestCase): diff --git a/test/suggestion/v1alpha3/test_hyperopt_service.py b/test/suggestion/v1alpha3/test_hyperopt_service.py index 969c5bf43a3..a3651b8a032 100644 --- a/test/suggestion/v1alpha3/test_hyperopt_service.py +++ b/test/suggestion/v1alpha3/test_hyperopt_service.py @@ -5,7 +5,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.hyperopt_service import HyperoptService +from pkg.suggestion.v1alpha3.hyperopt.service import HyperoptService class TestHyperopt(unittest.TestCase): diff --git a/test/suggestion/v1alpha3/test_skopt_service.py b/test/suggestion/v1alpha3/test_skopt_service.py index 77ee97566d3..26014d5e83c 100644 --- a/test/suggestion/v1alpha3/test_skopt_service.py +++ b/test/suggestion/v1alpha3/test_skopt_service.py @@ -5,7 +5,7 @@ from pkg.apis.manager.v1alpha3.python import api_pb2_grpc from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.suggestion.v1alpha3.skopt_service import SkoptService +from pkg.suggestion.v1alpha3.skopt.service import SkoptService class TestSkopt(unittest.TestCase):