Skip to content

Commit

Permalink
Fix duplicated imports (kubeflow#1133)
Browse files Browse the repository at this point in the history
* Avoid star-imports

* Add constants
  • Loading branch information
c-bata authored and sperlingxx committed Apr 20, 2020
1 parent ef0b294 commit 7776ae8
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
6 changes: 2 additions & 4 deletions pkg/suggestion/v1alpha3/chocolate/base_chocolate_service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import json
import numpy as np
import chocolate as choco
import logging
import base64

from pkg.suggestion.v1alpha3.internal.search_space import *
from pkg.suggestion.v1alpha3.internal.trial import *
from pkg.suggestion.v1alpha3.internal.constant import *
from pkg.suggestion.v1alpha3.internal.trial import Assignment

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions pkg/suggestion/v1alpha3/chocolate_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from pkg.apis.manager.v1alpha3.python import api_pb2
from pkg.apis.manager.v1alpha3.python import api_pb2_grpc
from pkg.apis.manager.health.python import health_pb2

from pkg.suggestion.v1alpha3.internal.search_space import HyperParameter, HyperParameterSearchSpace, DOUBLE
from pkg.suggestion.v1alpha3.internal.constant import *
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
Expand Down
6 changes: 3 additions & 3 deletions pkg/suggestion/v1alpha3/hyperopt/base_hyperopt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import numpy as np
import logging

from pkg.suggestion.v1alpha3.internal.search_space import *
from pkg.suggestion.v1alpha3.internal.trial import *
from pkg.suggestion.v1alpha3.internal.constant import *
from pkg.suggestion.v1alpha3.internal.trial import Assignment

logger = logging.getLogger(__name__)

TPE_ALGORITHM_NAME = "tpe"
RANDOM_ALGORITHM_NAME = "random"


class BaseHyperoptService(object):
def __init__(self, algorithm_name=TPE_ALGORITHM_NAME, random_state=None, search_space=None):
self.algorithm_name = algorithm_name
Expand Down Expand Up @@ -64,7 +65,6 @@ def create_fmin(self):

self.fmin.catch_eval_exceptions = False


def getSuggestions(self, trials, request_number):
"""
Get the new suggested trials with the given algorithm.
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions pkg/suggestion/v1alpha3/internal/constant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MAX_GOAL = "MAXIMIZE"
MIN_GOAL = "MINIMIZE"

INTEGER = "INTEGER"
DOUBLE = "DOUBLE"
CATEGORICAL = "CATEGORICAL"
DISCRETE = "DISCRETE"
7 changes: 1 addition & 6 deletions pkg/suggestion/v1alpha3/internal/search_space.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import logging
from pkg.apis.manager.v1alpha3.python import api_pb2 as api

MAX_GOAL = "MAXIMIZE"
MIN_GOAL = "MINIMIZE"
from .constant import *

INTEGER = "INTEGER"
DOUBLE = "DOUBLE"
CATEGORICAL = "CATEGORICAL"
DISCRETE = "DISCRETE"

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
Expand Down
10 changes: 4 additions & 6 deletions pkg/suggestion/v1alpha3/skopt/base_skopt_service.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import json
import numpy as np
import skopt
import datetime
import logging
import skopt

from pkg.suggestion.v1alpha3.internal.search_space import *
from pkg.suggestion.v1alpha3.internal.trial import *
import datetime
from pkg.suggestion.v1alpha3.internal.constant import *
from pkg.suggestion.v1alpha3.internal.trial import Assignment

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion pkg/suggestion/v1alpha3/skopt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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.skopt.base_skopt_service import BaseSkoptService
from pkg.suggestion.v1alpha3.base_health_service import HealthServicer
Expand Down

0 comments on commit 7776ae8

Please sign in to comment.