From a90d39624efef24b41bfbecf61cedd467869fe7c Mon Sep 17 00:00:00 2001 From: Masashi SHIBATA Date: Tue, 24 Mar 2020 15:30:46 +0900 Subject: [PATCH] Refactor python files of suggestion services (#1107) --- pkg/suggestion/v1alpha3/base_health_service.py | 3 +-- pkg/suggestion/v1alpha3/hyperband_service.py | 1 + pkg/suggestion/v1alpha3/hyperopt_service.py | 2 +- pkg/suggestion/v1alpha3/nasrl_service.py | 6 +++--- pkg/suggestion/v1alpha3/parameter.py | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/suggestion/v1alpha3/base_health_service.py b/pkg/suggestion/v1alpha3/base_health_service.py index 6da6787302a..adb6d8506dd 100644 --- a/pkg/suggestion/v1alpha3/base_health_service.py +++ b/pkg/suggestion/v1alpha3/base_health_service.py @@ -24,8 +24,7 @@ SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name -class _Watcher(): - +class _Watcher: def __init__(self): self._condition = threading.Condition() self._responses = collections.deque() diff --git a/pkg/suggestion/v1alpha3/hyperband_service.py b/pkg/suggestion/v1alpha3/hyperband_service.py index 32f0754dfb4..d508687c3de 100644 --- a/pkg/suggestion/v1alpha3/hyperband_service.py +++ b/pkg/suggestion/v1alpha3/hyperband_service.py @@ -17,6 +17,7 @@ logger.setLevel(DEBUG) logger.addHandler(handler) + class HyperbandService(api_pb2_grpc.SuggestionServicer, HealthServicer): def GetSuggestions(self, request, context): """ diff --git a/pkg/suggestion/v1alpha3/hyperopt_service.py b/pkg/suggestion/v1alpha3/hyperopt_service.py index 9a46390af5e..b997b468192 100644 --- a/pkg/suggestion/v1alpha3/hyperopt_service.py +++ b/pkg/suggestion/v1alpha3/hyperopt_service.py @@ -3,7 +3,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.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 diff --git a/pkg/suggestion/v1alpha3/nasrl_service.py b/pkg/suggestion/v1alpha3/nasrl_service.py index 4e0033a12e8..61354095b0d 100644 --- a/pkg/suggestion/v1alpha3/nasrl_service.py +++ b/pkg/suggestion/v1alpha3/nasrl_service.py @@ -1,8 +1,7 @@ import logging -from logging import getLogger, StreamHandler, INFO, DEBUG +from logging import getLogger, StreamHandler, INFO import json import os -import time import tensorflow as tf import grpc @@ -13,7 +12,8 @@ from pkg.suggestion.v1alpha3.NAS_Reinforcement_Learning.AlgorithmSettings import parseAlgorithmSettings from pkg.suggestion.v1alpha3.base_health_service import HealthServicer -class NAS_RL_Experiment(object): + +class NAS_RL_Experiment: def __init__(self, request, logger): self.logger = logger self.experiment_name = request.experiment.name diff --git a/pkg/suggestion/v1alpha3/parameter.py b/pkg/suggestion/v1alpha3/parameter.py index 8918fd877de..e2c03e16246 100644 --- a/pkg/suggestion/v1alpha3/parameter.py +++ b/pkg/suggestion/v1alpha3/parameter.py @@ -1,6 +1,7 @@ import numpy as np from sklearn.preprocessing import MinMaxScaler + class ParameterConfig: """ Class to hold the parameter configuration for an experiment.