diff --git a/cmd/suggestion/bayesianoptimization/v1alpha3/Dockerfile b/cmd/suggestion/bayesianoptimization/v1alpha3/Dockerfile deleted file mode 100644 index bf900b5ff94..00000000000 --- a/cmd/suggestion/bayesianoptimization/v1alpha3/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM python:3 - -ADD . /usr/src/app/github.com/kubeflow/katib -WORKDIR /usr/src/app/github.com/kubeflow/katib/cmd/suggestion/bayesianoptimization/v1alpha3 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - apt-get update && apt-get -y install libblas-dev liblapack-dev libatlas-base-dev gfortran && \ - pip install cython; \ - fi -RUN pip install --no-cache-dir -r requirements.txt -ENV PYTHONPATH /usr/src/app/github.com/kubeflow/katib:/usr/src/app/github.com/kubeflow/katib/pkg/apis/manager/v1alpha3/python - -ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/bayesianoptimization/v1alpha3/README.md b/cmd/suggestion/bayesianoptimization/v1alpha3/README.md deleted file mode 100644 index 89788a8ae67..00000000000 --- a/cmd/suggestion/bayesianoptimization/v1alpha3/README.md +++ /dev/null @@ -1,14 +0,0 @@ -- start the service - -``` -python suggestion/bayesian/main.py -``` - -- start the testing client - -``` -python suggestion/test_client.py -``` - -note: -the testing client uses the [Franke's function](http://www.sfu.ca/~ssurjano/franke2d.html) as the black box, and the maximum of Franke's function is around 1.22 diff --git a/cmd/suggestion/bayesianoptimization/v1alpha3/__init__.py b/cmd/suggestion/bayesianoptimization/v1alpha3/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/cmd/suggestion/bayesianoptimization/v1alpha3/main.py b/cmd/suggestion/bayesianoptimization/v1alpha3/main.py deleted file mode 100644 index 72e8691e07d..00000000000 --- a/cmd/suggestion/bayesianoptimization/v1alpha3/main.py +++ /dev/null @@ -1,25 +0,0 @@ -import grpc -from concurrent import futures - -import time - -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3.bayesian_service import BayesianService - -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 -DEFAULT_PORT = "0.0.0.0:6789" - -def serve(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - api_pb2_grpc.add_SuggestionServicer_to_server(BayesianService(), server) - server.add_insecure_port(DEFAULT_PORT) - print("Listening...") - server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) - -if __name__ == "__main__": - serve() diff --git a/cmd/suggestion/bayesianoptimization/v1alpha3/requirements.txt b/cmd/suggestion/bayesianoptimization/v1alpha3/requirements.txt deleted file mode 100644 index 8d2c9d4bda7..00000000000 --- a/cmd/suggestion/bayesianoptimization/v1alpha3/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -grpcio -duecredit -cloudpickle==0.5.6 -numpy>=1.13.3 -scikit-learn>=0.19.0 -scipy>=0.19.1 -forestci -protobuf -googleapis-common-protos diff --git a/cmd/suggestion/grid/v1alpha3/Dockerfile b/cmd/suggestion/grid/v1alpha3/Dockerfile deleted file mode 100644 index 2cacefd18f1..00000000000 --- a/cmd/suggestion/grid/v1alpha3/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM python:3 - -ADD . /usr/src/app/github.com/kubeflow/katib -WORKDIR /usr/src/app/github.com/kubeflow/katib/cmd/suggestion/grid/v1alpha3 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - apt-get -y update && \ - apt-get -y install gfortran libopenblas-dev liblapack-dev && \ - pip install cython; \ - fi -RUN pip install --no-cache-dir -r requirements.txt -ENV PYTHONPATH /usr/src/app/github.com/kubeflow/katib:/usr/src/app/github.com/kubeflow/katib/pkg/apis/manager/v1alpha3/python - -ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/grid/v1alpha3/__init__.py b/cmd/suggestion/grid/v1alpha3/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/cmd/suggestion/grid/v1alpha3/main.py b/cmd/suggestion/grid/v1alpha3/main.py deleted file mode 100644 index 2a9194f48ed..00000000000 --- a/cmd/suggestion/grid/v1alpha3/main.py +++ /dev/null @@ -1,23 +0,0 @@ -import grpc -import time -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3.grid_service import GridService -from concurrent import futures - -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 -DEFAULT_PORT = "0.0.0.0:6789" - -def serve(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - api_pb2_grpc.add_SuggestionServicer_to_server(GridService(), server) - server.add_insecure_port(DEFAULT_PORT) - print("Listening...") - server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) - -if __name__ == "__main__": - serve() diff --git a/cmd/suggestion/grid/v1alpha3/requirements.txt b/cmd/suggestion/grid/v1alpha3/requirements.txt deleted file mode 100644 index 8d2c9d4bda7..00000000000 --- a/cmd/suggestion/grid/v1alpha3/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -grpcio -duecredit -cloudpickle==0.5.6 -numpy>=1.13.3 -scikit-learn>=0.19.0 -scipy>=0.19.1 -forestci -protobuf -googleapis-common-protos diff --git a/cmd/suggestion/random/v1alpha3/Dockerfile b/cmd/suggestion/random/v1alpha3/Dockerfile deleted file mode 100644 index fd294fd79b6..00000000000 --- a/cmd/suggestion/random/v1alpha3/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM python:3 - -ADD . /usr/src/app/github.com/kubeflow/katib -WORKDIR /usr/src/app/github.com/kubeflow/katib/cmd/suggestion/random/v1alpha3 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - apt-get -y update && \ - apt-get -y install gfortran libopenblas-dev liblapack-dev && \ - pip install cython; \ - fi -RUN pip install --no-cache-dir -r requirements.txt -ENV PYTHONPATH /usr/src/app/github.com/kubeflow/katib:/usr/src/app/github.com/kubeflow/katib/pkg/apis/manager/v1alpha3/python - -ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/random/v1alpha3/__init__.py b/cmd/suggestion/random/v1alpha3/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/cmd/suggestion/random/v1alpha3/main.py b/cmd/suggestion/random/v1alpha3/main.py deleted file mode 100644 index db000ca7532..00000000000 --- a/cmd/suggestion/random/v1alpha3/main.py +++ /dev/null @@ -1,23 +0,0 @@ -import grpc -import time -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3.random_service import RandomService -from concurrent import futures - -_ONE_DAY_IN_SECONDS = 60 * 60 * 24 -DEFAULT_PORT = "0.0.0.0:6789" - -def serve(): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - api_pb2_grpc.add_SuggestionServicer_to_server(RandomService(), server) - server.add_insecure_port(DEFAULT_PORT) - print("Listening...") - server.start() - try: - while True: - time.sleep(_ONE_DAY_IN_SECONDS) - except KeyboardInterrupt: - server.stop(0) - -if __name__ == "__main__": - serve() diff --git a/cmd/suggestion/random/v1alpha3/requirements.txt b/cmd/suggestion/random/v1alpha3/requirements.txt deleted file mode 100644 index 8d2c9d4bda7..00000000000 --- a/cmd/suggestion/random/v1alpha3/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -grpcio -duecredit -cloudpickle==0.5.6 -numpy>=1.13.3 -scikit-learn>=0.19.0 -scipy>=0.19.1 -forestci -protobuf -googleapis-common-protos diff --git a/examples/v1alpha3/bayseopt-example.yaml b/examples/v1alpha3/bayseopt-example.yaml deleted file mode 100644 index 1e02bee1056..00000000000 --- a/examples/v1alpha3/bayseopt-example.yaml +++ /dev/null @@ -1,65 +0,0 @@ -apiVersion: "kubeflow.org/v1alpha3" -kind: Experiment -metadata: - namespace: kubeflow - labels: - controller-tools.k8s.io: "1.0" - name: bayseopt-example -spec: - objective: - type: maximize - goal: 0.99 - objectiveMetricName: Validation-accuracy - additionalMetricNames: - - accuracy - algorithm: - algorithmName: bayesianoptimization - algorithmSettings: - - name: "burn_in" - value: "5" - parallelTrialCount: 3 - maxTrialCount: 12 - maxFailedTrialCount: 3 - parameters: - - name: --lr - parameterType: double - feasibleSpace: - min: "0.01" - max: "0.03" - - name: --num-layers - parameterType: int - feasibleSpace: - min: "2" - max: "5" - - name: --optimizer - parameterType: categorical - feasibleSpace: - list: - - sgd - - adam - - ftrl - trialTemplate: - goTemplate: - rawTemplate: |- - apiVersion: batch/v1 - kind: Job - metadata: - name: {{.Trial}} - namespace: {{.NameSpace}} - spec: - template: - spec: - serviceAccountName: metrics-collector - containers: - - name: {{.Trial}} - image: katib/mxnet-mnist-example - command: - - "python" - - "/mxnet/example/image-classification/train_mnist.py" - - "--batch-size=64" - {{- with .HyperParameters}} - {{- range .}} - - "{{.Name}}={{.Value}}" - {{- end}} - {{- end}} - restartPolicy: Never diff --git a/examples/v1alpha3/grid-example.yaml b/examples/v1alpha3/grid-example.yaml deleted file mode 100644 index 49dfb23563d..00000000000 --- a/examples/v1alpha3/grid-example.yaml +++ /dev/null @@ -1,65 +0,0 @@ -apiVersion: "kubeflow.org/v1alpha3" -kind: Experiment -metadata: - namespace: kubeflow - name: grid-experiment -spec: - parallelTrialCount: 3 - maxTrialCount: 12 - maxFailedTrialCount: 3 - objective: - type: maximize - goal: 0.99 - objectiveMetricName: Validation-accuracy - additionalMetricNames: - - accuracy - algorithm: - algorithmName: grid - algorithmSettings: - - name: --num-layers - value: "5" - - name: --optimizer - value: "3" - trialTemplate: - goTemplate: - rawTemplate: |- - apiVersion: batch/v1 - kind: Job - metadata: - name: {{.Trial}} - namespace: {{.NameSpace}} - spec: - template: - spec: - serviceAccountName: metrics-collector # will be dropped - containers: - - name: {{.Trial}} - image: katib/mxnet-mnist-example - command: - - "python" - - "/mxnet/example/image-classification/train_mnist.py" - - "--batch-size=64" - {{- with .HyperParameters}} - {{- range .}} - - "{{.Name}}={{.Value}}" - {{- end}} - {{- end}} - restartPolicy: Never - parameters: - - name: --lr - parameterType: double - feasibleSpace: - min: "0.01" - max: "0.03" - - name: --num-layers - parameterType: int - feasibleSpace: - min: "1" - max: "15" - - name: --optimizer - parameterType: categorical - feasibleSpace: - list: - - sgd - - adam - - ftrl diff --git a/examples/v1alpha3/random-example.yaml b/examples/v1alpha3/random-example.yaml deleted file mode 100644 index f73adfa595b..00000000000 --- a/examples/v1alpha3/random-example.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: "kubeflow.org/v1alpha3" -kind: Experiment -metadata: - namespace: kubeflow - name: random-experiment -spec: - parallelTrialCount: 3 - maxTrialCount: 12 - maxFailedTrialCount: 3 - objective: - type: maximize - goal: 0.99 - objectiveMetricName: Validation-accuracy - additionalMetricNames: - - accuracy - algorithm: - algorithmName: random - trialTemplate: - goTemplate: - rawTemplate: |- - apiVersion: batch/v1 - kind: Job - metadata: - name: {{.Trial}} - namespace: {{.NameSpace}} - spec: - template: - spec: - serviceAccountName: metrics-collector - containers: - - name: {{.Trial}} - image: katib/mxnet-mnist-example - command: - - "python" - - "/mxnet/example/image-classification/train_mnist.py" - - "--batch-size=64" - - "--num-epochs=1" - {{- with .HyperParameters}} - {{- range .}} - - "{{.Name}}={{.Value}}" - {{- end}} - {{- end}} - restartPolicy: Never - parameters: - - name: --lr - parameterType: double - feasibleSpace: - min: "0.01" - max: "0.03" - - name: --num-layers - parameterType: int - feasibleSpace: - min: "2" - max: "5" - - name: --optimizer - parameterType: categorical - feasibleSpace: - list: - - sgd - - adam - - ftrl diff --git a/pkg/suggestion/v1alpha3/bayesian_service.py b/pkg/suggestion/v1alpha3/bayesian_service.py deleted file mode 100644 index 7ff1111169b..00000000000 --- a/pkg/suggestion/v1alpha3/bayesian_service.py +++ /dev/null @@ -1,220 +0,0 @@ -import random -import string - -import grpc -import numpy as np - -from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from pkg.suggestion.v1alpha3.bayesianoptimization.src.bayesian_optimization_algorithm import BOAlgorithm -from pkg.suggestion.v1alpha3.bayesianoptimization.src.algorithm_manager import AlgorithmManager -import logging -from logging import getLogger, StreamHandler, INFO, DEBUG -from . import parsing_util - -timeout = 10 - -class BayesianService(api_pb2_grpc.SuggestionServicer): - def __init__(self, logger=None): - self.manager_addr = "katib-manager" - self.manager_port = 6789 - if logger == None: - self.logger = getLogger(__name__) - FORMAT = '%(asctime)-15s Experiment %(experiment_name)s %(message)s' - logging.basicConfig(format=FORMAT) - handler = StreamHandler() - handler.setLevel(DEBUG) - self.logger.setLevel(DEBUG) - self.logger.addHandler(handler) - self.logger.propagate = False - else: - self.logger = logger - - def _get_experiment(self, name): - channel = grpc.beta.implementations.insecure_channel( - self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - exp = client.GetExperiment( - api_pb2.GetExperimentRequest(experiment_name=name), timeout) - return exp.experiment - - def ValidateAlgorithmSettings(self, request, context): - return api_pb2.ValidateAlgorithmSettingsReply() - - def GetSuggestions(self, request, context): - """ - Main function to provide suggestion. - """ - service_params = self.parseParameters(request.experiment_name) - experiment = self._get_experiment(request.experiment_name) - X_train, y_train = self.getEvalHistory( - request.experiment_name, experiment.spec.objective.objective_metric_name, service_params["burn_in"]) - - parameter_config = parsing_util.parse_parameter_configs( - experiment.spec.parameter_specs.parameters) - algo_manager = AlgorithmManager( - experiment_name=request.experiment_name, - experiment=experiment, - parameter_config=parameter_config, - X_train=X_train, - y_train=y_train, - logger=self.logger, - ) - - lowerbound = np.array(algo_manager.lower_bound) - upperbound = np.array(algo_manager.upper_bound) - self.logger.debug("lowerbound: %r", lowerbound, - extra={"experiment_name": request.experiment_name}) - self.logger.debug("upperbound: %r", upperbound, - extra={"experiment_name": request.experiment_name}) - alg = BOAlgorithm( - experiment_name=request.experiment_name, - dim=algo_manager.dim, - N=int(service_params["N"]), - lowerbound=lowerbound, - upperbound=upperbound, - X_train=algo_manager.X_train, - y_train=algo_manager.y_train, - mode=service_params["mode"], - trade_off=service_params["trade_off"], - # todo: support length_scale with array type - length_scale=service_params["length_scale"], - noise=service_params["noise"], - nu=service_params["nu"], - kernel_type=service_params["kernel_type"], - n_estimators=service_params["n_estimators"], - max_features=service_params["max_features"], - model_type=service_params["model_type"], - logger=self.logger, - ) - self.logger.debug("alg: %r", alg, - extra={"experiment_name": request.experiment_name}) - trials = [] - x_next_list = alg.get_suggestion(request.request_number) - self.logger.debug("x_next_list: %r", x_next_list, - extra={"experiment_name": request.experiment_name}) - for x_next in x_next_list: - x_next = x_next.squeeze() - self.logger.debug("xnext: %r ", x_next, extra={ - "experiment_name": request.experiment_name}) - x_next = algo_manager.parse_x_next(x_next) - x_next = algo_manager.convert_to_dict(x_next) - trials.append(api_pb2.Trial( - spec=api_pb2.TrialSpec( - experiment_name=request.experiment_name, - parameter_assignments=api_pb2.TrialSpec.ParameterAssignments( - assignments=[ - api_pb2.ParameterAssignment( - name=x["name"], - value=str(x["value"]), - ) for x in x_next - ] - ) - ) - )) - return api_pb2.GetSuggestionsReply( - trials=trials - ) - - def getEvalHistory(self, experiment_name, obj_name, burn_in): - worker_hist = [] - x_train = [] - y_train = [] - channel = grpc.beta.implementations.insecure_channel( - self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - trialsrep = client.GetTrialList(api_pb2.GetTrialListRequest( - experiment_name=experiment_name - ), timeout) - for t in trialsrep.trials: - if t.status.condition == api_pb2.TrialStatus.TrialConditionType.SUCCEEDED: - gwfrep = client.GetObservationLog( - api_pb2.GetObservationLogRequest( - trial_name=t.name, - metric_name=obj_name), timeout) - w = gwfrep.observation_log - for ml in w.metric_logs: - y_train.append(float(ml.metric.value)) - x_train.append(t.spec.parameter_assignments.assignments) - self.logger.info("%d completed trials are found.", - len(x_train), extra={"Experiment": experiment_name}) - if len(x_train) <= burn_in: - x_train = [] - y_train = [] - self.logger.info("Trials will be sampled until %d trials for burn-in are completed.", - burn_in, extra={"experiment_name": experiment_name}) - else: - self.logger.debug("Completed trials: %r", x_train, - extra={"experiment_name": experiment_name}) - - return x_train, y_train - - def parseParameters(self, experiment_name): - channel = grpc.beta.implementations.insecure_channel( - self.manager_addr, self.manager_port) - params = [] - with api_pb2.beta_create_Manager_stub(channel) as client: - gsprep = client.GetAlgorithmExtraSettings( - api_pb2.GetAlgorithmExtraSettingsRequest(experiment_name=experiment_name), timeout) - params = gsprep.extra_algorithm_settings - - parsed_service_params = { - "N": 100, - "model_type": "gp", - "max_features": "auto", - "length_scale": 0.5, - "noise": 0.0005, - "nu": 1.5, - "kernel_type": "matern", - "n_estimators": 50, - "mode": "pi", - "trade_off": 0.01, - "trial_hist": "", - "burn_in": 10, - } - modes = ["pi", "ei"] - model_types = ["gp", "rf"] - kernel_types = ["matern", "rbf"] - - for param in params: - if param.name in parsed_service_params.keys(): - if param.name == "length_scale" or param.name == "noise" or param.name == "nu" or param.name == "trade_off": - try: - float(param.value) - except ValueError: - self.logger.warning( - "Parameter must be float for %s: %s back to default value", param.name, param.value) - else: - parsed_service_params[param.name] = float(param.value) - - elif param.name == "N" or param.name == "n_estimators" or param.name == "burn_in": - try: - int(param.value) - except ValueError: - self.logger.warning( - "Parameter must be int for %s: %s back to default value", param.name, param.value) - else: - parsed_service_params[param.name] = int(param.value) - - elif param.name == "kernel_type": - if param.value != "rbf" and param.value != "matern": - parsed_service_params[param.name] = param.value - else: - self.logger.warning( - "Unknown Parameter for %s: %s back to default value", param.name, param.value) - elif param.name == "mode" and param.value in modes: - if param.value != "lcb" and param.value != "ei" and param.value != "pi": - parsed_service_params[param.name] = param.value - else: - self.logger.warning( - "Unknown Parameter for %s: %s back to default value", param.name, param.value) - elif param.name == "model_type" and param.value in model_types: - if param.value != "rf" and param.value != "gp": - parsed_service_params[param.name] = param.value - else: - self.logger.warning( - "Unknown Parameter for %s: %s back to default value", param.name, param.value) - else: - self.logger.warning("Unknown Parameter name: %s ", param.name) - - return parsed_service_params diff --git a/pkg/suggestion/v1alpha3/grid_service.py b/pkg/suggestion/v1alpha3/grid_service.py deleted file mode 100644 index 1d1088e8878..00000000000 --- a/pkg/suggestion/v1alpha3/grid_service.py +++ /dev/null @@ -1,110 +0,0 @@ -from logging import getLogger, StreamHandler, INFO, DEBUG -import itertools -import grpc -import numpy as np -from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -from . import parsing_util - -class GridService(api_pb2_grpc.SuggestionServicer): - def __init__(self): - self.manager_addr = "katib-manager" - self.manager_port = 6789 - self.default_grid = 10 - - def _get_experiment(self, name): - channel = grpc.beta.implementations.insecure_channel(self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - exp = client.GetExperiment(api_pb2.GetExperimentRequest(experiment_name=name), 10) - return exp.experiment - - def _get_algorithm_settings(self, experiment_name): - channel = grpc.beta.implementations.insecure_channel(self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - alg = client.GetAlgorithmExtraSettings(api_pb2.GetAlgorithmExtraSettingsRequest( - experiment_name=experiment_name), 10) - params = alg.extra_algorithm_settings - alg_settings = {} - for param in params: - alg_settings[param.name] = param.value - return alg_settings - - def _get_trials(self, experiment_name): - channel = grpc.beta.implementations.insecure_channel(self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - trials = client.GetTrialList(api_pb2.GetTrialListRequest( - experiment_name=experiment_name), 10) - return trials.trials - - def _create_all_combinations(self, parameters, alg_settings): - param_ranges = [] - cur_index = 0 - parameter_config = parsing_util.parse_parameter_configs(parameters) - default_grid_size = alg_settings.get("DefaultGrid", self.default_grid) - for idx, param_type in enumerate(parameter_config.parameter_types): - param_name = parameter_config.names[idx] - if param_type in [api_pb2.DOUBLE, api_pb2.INT]: - num = alg_settings.get(param_name, default_grid_size) - param_values = \ - np.linspace(parameter_config.lower_bounds[0, cur_index], - parameter_config.upper_bounds[0, cur_index], - num=num) - cur_index += 1 - if param_type == api_pb2.INT: - param_values = param_values.astype(np.int64) - elif param_type == api_pb2.DISCRETE: - for discrete_param in parameter_config.discrete_info: - if param_name == discrete_param["name"]: - param_values = discrete_param["values"] - break - cur_index += 1 - elif param_type == api_pb2.CATEGORICAL: - for categ_param in parameter_config.categorical_info: - if param_name == categ_param["name"]: - param_values = categ_param["values"] - break - cur_index += categ_param["number"] - param_ranges.append(param_values) - all_combinations = [comb for comb in itertools.product(*param_ranges)] - return all_combinations, parameter_config - - def GetSuggestions(self, request, context): - """ - Main function to provide suggestion. - """ - experiment_name = request.experiment_name - request_number = request.request_number - experiment = self._get_experiment(experiment_name) - parameters = experiment.spec.parameter_specs.parameters - alg_settings = self._get_algorithm_settings(experiment_name) - combinations, parameter_config = self._create_all_combinations(parameters, alg_settings) - total_combinations = len(combinations) - - allocated_trials = self._get_trials(experiment_name) - total_allocated_trials = len(allocated_trials) - return_start_index = total_allocated_trials - return_end_index = return_start_index + request_number - - if return_start_index > total_combinations: - return_start_index = 0 - return_end_index = return_start_index + request_number - elif return_start_index + request_number > total_combinations: - return_start_index = total_combinations - request_number - return_end_index = total_combinations - if return_start_index < 0: - return_start_index = 0 - - trial_specs = [] - for elem in combinations[return_start_index:return_end_index]: - suggestion = parsing_util.parse_x_next_tuple(elem, parameter_config.parameter_types, - parameter_config.names) - trial_spec = api_pb2.TrialSpec() - trial_spec.experiment_name = experiment_name - for param in suggestion: - trial_spec.parameter_assignments.assignments.add(name=param['name'], - value=str(param['value'])) - trial_specs.append(trial_spec) - reply = api_pb2.GetSuggestionsReply() - for trial_spec in trial_specs: - reply.trials.add(spec=trial_spec) - return reply diff --git a/pkg/suggestion/v1alpha3/random_service.py b/pkg/suggestion/v1alpha3/random_service.py deleted file mode 100644 index 6f333e28511..00000000000 --- a/pkg/suggestion/v1alpha3/random_service.py +++ /dev/null @@ -1,44 +0,0 @@ -from logging import getLogger, StreamHandler, INFO, DEBUG -from pkg.apis.manager.v1alpha3.python import api_pb2 -from pkg.apis.manager.v1alpha3.python import api_pb2_grpc -import grpc -from . import parsing_util - -class RandomService(api_pb2_grpc.SuggestionServicer): - def __init__(self): - self.manager_addr = "katib-manager" - self.manager_port = 6789 - - def _get_experiment(self, name): - channel = grpc.beta.implementations.insecure_channel(self.manager_addr, self.manager_port) - with api_pb2.beta_create_Manager_stub(channel) as client: - exp = client.GetExperiment(api_pb2.GetExperimentRequest(experiment_name=name), 10) - return exp.experiment - - def GetSuggestions(self, request, context): - """ - Main function to provide suggestion. - """ - experiment = self._get_experiment(request.experiment_name) - parameter_config = parsing_util.parse_parameter_configs( - experiment.spec.parameter_specs.parameters) - trial_specs = [] - for _ in range(request.request_number): - sample = parameter_config.random_sample() - suggestion = parsing_util.parse_x_next_vector(sample, - parameter_config.parameter_types, - parameter_config.names, - parameter_config.discrete_info, - parameter_config.categorical_info) - trial_spec = api_pb2.TrialSpec() - trial_spec.experiment_name = request.experiment_name - for param in suggestion: - trial_spec.parameter_assignments.assignments.add(name=param['name'], - value=str(param['value'])) - trial_specs.append(trial_spec) - - reply = api_pb2.GetSuggestionsReply() - for trial_spec in trial_specs: - reply.trials.add(spec=trial_spec) - - return reply diff --git a/test/scripts/v1alpha3/build-suggestion-bo.sh b/test/scripts/v1alpha3/build-suggestion-bo.sh deleted file mode 100755 index 8487a3447f3..00000000000 --- a/test/scripts/v1alpha3/build-suggestion-bo.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Kubeflow Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This shell script is used to build an image from our argo workflow - -set -o errexit -set -o nounset -set -o pipefail - -export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} -REGISTRY="${GCP_REGISTRY}" -PROJECT="${GCP_PROJECT}" -GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-bo -VERSION=$(git describe --tags --always --dirty) - -echo "Activating service-account" -gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} - -echo "Copy source to GOPATH" -mkdir -p ${GO_DIR} -cp -r cmd ${GO_DIR}/cmd -cp -r pkg ${GO_DIR}/pkg -cp -r vendor ${GO_DIR}/vendor - -cd ${GO_DIR} - -cp cmd/suggestion/bayesianoptimization/v1alpha3/Dockerfile . -gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-bayesianoptimization:${VERSION} --project=${PROJECT} -gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-bayesianoptimization:${VERSION} ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-bayesianoptimization:latest --verbosity=info diff --git a/test/scripts/v1alpha3/build-suggestion-grid.sh b/test/scripts/v1alpha3/build-suggestion-grid.sh deleted file mode 100755 index 8577f1a5445..00000000000 --- a/test/scripts/v1alpha3/build-suggestion-grid.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Kubeflow Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This shell script is used to build an image from our argo workflow - -set -o errexit -set -o nounset -set -o pipefail - -export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} -REGISTRY="${GCP_REGISTRY}" -PROJECT="${GCP_PROJECT}" -GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-grid -VERSION=$(git describe --tags --always --dirty) - -echo "Activating service-account" -gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} - -echo "Copy source to GOPATH" -mkdir -p ${GO_DIR} -cp -r cmd ${GO_DIR}/cmd -cp -r pkg ${GO_DIR}/pkg -cp -r vendor ${GO_DIR}/vendor - -cd ${GO_DIR} - -cp cmd/suggestion/grid/v1alpha3/Dockerfile . -gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-grid:${VERSION} --project=${PROJECT} -gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-grid:${VERSION} ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-grid:latest --verbosity=info diff --git a/test/scripts/v1alpha3/build-suggestion-random.sh b/test/scripts/v1alpha3/build-suggestion-random.sh deleted file mode 100755 index a6bba44386f..00000000000 --- a/test/scripts/v1alpha3/build-suggestion-random.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Kubeflow Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This shell script is used to build an image from our argo workflow - -set -o errexit -set -o nounset -set -o pipefail - -export PATH=${GOPATH}/bin:/usr/local/go/bin:${PATH} -REGISTRY="${GCP_REGISTRY}" -PROJECT="${GCP_PROJECT}" -GO_DIR=${GOPATH}/src/github.com/${REPO_OWNER}/${REPO_NAME}-suggestion-random -VERSION=$(git describe --tags --always --dirty) - -echo "Activating service-account" -gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} - -echo "Copy source to GOPATH" -mkdir -p ${GO_DIR} -cp -r cmd ${GO_DIR}/cmd -cp -r pkg ${GO_DIR}/pkg -cp -r vendor ${GO_DIR}/vendor - -cd ${GO_DIR} - -cp cmd/suggestion/random/v1alpha3/Dockerfile . -gcloud builds submit . --tag=${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-random:${VERSION} --project=${PROJECT} -gcloud container images add-tag --quiet ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-random:${VERSION} ${REGISTRY}/${REPO_NAME}/v1alpha3/suggestion-random:latest --verbosity=info diff --git a/test/scripts/v1alpha3/run-tests.sh b/test/scripts/v1alpha3/run-tests.sh index 5e33ebb3bde..fb21a6954f5 100755 --- a/test/scripts/v1alpha3/run-tests.sh +++ b/test/scripts/v1alpha3/run-tests.sh @@ -81,10 +81,7 @@ sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/katib-manag sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/katib-ui@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/katib-ui:${VERSION}@" manifests/v1alpha3/ui/deployment.yaml # Suggestion algorithms -sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-random@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-random:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml -sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-bayesianoptimization@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-bayesianoptimization:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-nasrl@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-nasrl:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml -sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-grid@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-grid:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml sed -i -e "s@image: gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-hyperband@image: ${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-hyperband:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml sed -i -e "s@gcr.io\/kubeflow-images-public\/katib\/v1alpha3\/suggestion-hyperopt@${REGISTRY}\/${REPO_NAME}\/v1alpha3\/suggestion-hyperopt:${VERSION}@" manifests/v1alpha3/katib-controller/katib-config.yaml diff --git a/test/workflows/components/workflows-v1alpha3.libsonnet b/test/workflows/components/workflows-v1alpha3.libsonnet index 01cbf07f1c1..f4bbe7d553e 100644 --- a/test/workflows/components/workflows-v1alpha3.libsonnet +++ b/test/workflows/components/workflows-v1alpha3.libsonnet @@ -205,10 +205,6 @@ name: "python-tests", template: "python-tests", }, - { - name: "build-suggestion-bo", - template: "build-suggestion-bo", - }, { name: "build-suggestion-nasrl", template: "build-suggestion-nasrl", @@ -225,14 +221,6 @@ name: "build-katib-controller", template: "build-katib-controller", }, - { - name: "build-suggestion-random", - template: "build-suggestion-random", - }, - { - name: "build-suggestion-grid", - template: "build-suggestion-grid", - }, { name: "build-suggestion-hyperband", template: "build-suggestion-hyperband", @@ -343,21 +331,12 @@ $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-katib-controller", testWorkerImage, [ "test/scripts/v1alpha3/build-katib-controller.sh", ]), // build-katib-controller - $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-random", testWorkerImage, [ - "test/scripts/v1alpha3/build-suggestion-random.sh", - ]), // build-suggestion-random - $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-grid", testWorkerImage, [ - "test/scripts/v1alpha3/build-suggestion-grid.sh", - ]), // build-suggestion-grid $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-hyperband", testWorkerImage, [ "test/scripts/v1alpha3/build-suggestion-hyperband.sh", ]), // build-suggestion-hyperband $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-hyperopt", testWorkerImage, [ "test/scripts/v1alpha3/build-suggestion-hyperopt.sh", ]), // build-suggestion-hyperopt - $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-bo", testWorkerImage, [ - "test/scripts/v1alpha3/build-suggestion-bo.sh", - ]), // build-suggestion-bo $.parts(namespace, name, overrides).e2e(prow_env, bucket).buildTemplate("build-suggestion-nasrl", testWorkerImage, [ "test/scripts/v1alpha3/build-suggestion-nasrl.sh", ]), // build-suggestion-nasrl