From 00d9930aef9a65a0e80350fcf3d5e454d05b648c Mon Sep 17 00:00:00 2001 From: droctothorpe Date: Mon, 6 May 2024 21:30:19 -0400 Subject: [PATCH] Begin enabling pre-commit hooks Signed-off-by: droctothorpe --- .github/workflows/pre-commit/action.yaml | 14 ++++ .pre-commit-config.yaml | 61 +++++++++++++++++ cmd/earlystopping/medianstop/v1beta1/main.py | 8 ++- .../v1beta1/tfevent-metricscollector/main.py | 9 ++- cmd/suggestion/hyperband/v1beta1/main.py | 8 ++- cmd/suggestion/hyperopt/v1beta1/main.py | 8 ++- cmd/suggestion/nas/darts/v1beta1/main.py | 7 +- cmd/suggestion/nas/enas/v1beta1/main.py | 6 +- cmd/suggestion/optuna/v1beta1/main.py | 8 ++- cmd/suggestion/pbt/v1beta1/main.py | 8 ++- cmd/suggestion/skopt/v1beta1/main.py | 8 ++- docs/release/changelog.py | 3 +- .../kubeflow-pipelines/mpi-job-horovod.py | 11 ++- .../darts-cnn-cifar10/architect.py | 3 +- .../trial-images/darts-cnn-cifar10/model.py | 4 +- .../darts-cnn-cifar10/operations.py | 2 +- .../darts-cnn-cifar10/run_trial.py | 11 ++- .../darts-cnn-cifar10/search_space.py | 1 + .../enas-cnn-cifar10/ModelConstructor.py | 26 +++++-- .../trial-images/enas-cnn-cifar10/RunTrial.py | 11 +-- .../enas-cnn-cifar10/op_library.py | 17 +++-- .../trial-images/pytorch-mnist/mnist.py | 3 +- .../trial-images/simple-pbt/pbt_test.py | 3 +- .../tf-mnist-with-summaries/mnist.py | 6 +- pkg/apis/manager/health/python/health_pb2.py | 4 +- .../manager/health/python/health_pb2_grpc.py | 1 - pkg/apis/manager/v1beta1/python/api_pb2.py | 6 +- .../manager/v1beta1/python/api_pb2_grpc.py | 3 +- .../v1beta1/medianstop/service.py | 6 +- pkg/metricscollector/v1beta1/common/pns.py | 3 +- .../tfevent_loader.py | 18 +++-- .../v1beta1/hyperband/parsing_util.py | 4 +- pkg/suggestion/v1beta1/hyperband/service.py | 7 +- .../v1beta1/hyperopt/base_service.py | 9 ++- pkg/suggestion/v1beta1/hyperopt/service.py | 8 ++- .../v1beta1/internal/search_space.py | 6 +- pkg/suggestion/v1beta1/internal/trial.py | 2 +- pkg/suggestion/v1beta1/nas/darts/service.py | 9 ++- pkg/suggestion/v1beta1/nas/enas/Controller.py | 2 +- pkg/suggestion/v1beta1/nas/enas/Operation.py | 2 + pkg/suggestion/v1beta1/nas/enas/service.py | 21 ++++-- pkg/suggestion/v1beta1/optuna/base_service.py | 12 +++- pkg/suggestion/v1beta1/optuna/service.py | 13 ++-- pkg/suggestion/v1beta1/pbt/service.py | 17 ++--- pkg/suggestion/v1beta1/skopt/base_service.py | 7 +- pkg/suggestion/v1beta1/skopt/service.py | 6 +- sdk/python/v1beta1/kubeflow/katib/__init__.py | 67 +++++++++++-------- .../kubeflow/katib/api/katib_client.py | 5 +- .../v1beta1/kubeflow/katib/api/search.py | 3 +- .../v1beta1/kubeflow/katib/api_client.py | 12 ++-- .../v1beta1/kubeflow/katib/configuration.py | 2 +- .../v1beta1/kubeflow/katib/models/__init__.py | 43 +++++++----- .../katib/models/v1beta1_algorithm_setting.py | 3 +- .../katib/models/v1beta1_algorithm_spec.py | 3 +- .../katib/models/v1beta1_collector_spec.py | 3 +- .../katib/models/v1beta1_config_map_source.py | 3 +- .../models/v1beta1_early_stopping_rule.py | 3 +- .../models/v1beta1_early_stopping_setting.py | 3 +- .../models/v1beta1_early_stopping_spec.py | 3 +- .../katib/models/v1beta1_experiment.py | 3 +- .../models/v1beta1_experiment_condition.py | 3 +- .../katib/models/v1beta1_experiment_list.py | 3 +- .../katib/models/v1beta1_experiment_spec.py | 3 +- .../katib/models/v1beta1_experiment_status.py | 3 +- .../katib/models/v1beta1_feasible_space.py | 3 +- .../katib/models/v1beta1_file_system_path.py | 3 +- .../katib/models/v1beta1_filter_spec.py | 3 +- .../katib/models/v1beta1_graph_config.py | 3 +- .../kubeflow/katib/models/v1beta1_metric.py | 3 +- .../katib/models/v1beta1_metric_strategy.py | 3 +- .../models/v1beta1_metrics_collector_spec.py | 3 +- .../katib/models/v1beta1_nas_config.py | 3 +- .../katib/models/v1beta1_objective_spec.py | 3 +- .../katib/models/v1beta1_observation.py | 3 +- .../katib/models/v1beta1_operation.py | 3 +- .../katib/models/v1beta1_optimal_trial.py | 3 +- .../models/v1beta1_parameter_assignment.py | 3 +- .../katib/models/v1beta1_parameter_spec.py | 3 +- .../katib/models/v1beta1_source_spec.py | 3 +- .../katib/models/v1beta1_suggestion.py | 3 +- .../models/v1beta1_suggestion_condition.py | 3 +- .../katib/models/v1beta1_suggestion_list.py | 3 +- .../katib/models/v1beta1_suggestion_spec.py | 3 +- .../katib/models/v1beta1_suggestion_status.py | 3 +- .../kubeflow/katib/models/v1beta1_trial.py | 3 +- .../katib/models/v1beta1_trial_assignment.py | 3 +- .../katib/models/v1beta1_trial_condition.py | 3 +- .../katib/models/v1beta1_trial_list.py | 3 +- .../models/v1beta1_trial_parameter_spec.py | 3 +- .../katib/models/v1beta1_trial_source.py | 3 +- .../katib/models/v1beta1_trial_spec.py | 3 +- .../katib/models/v1beta1_trial_status.py | 3 +- .../katib/models/v1beta1_trial_template.py | 3 +- sdk/python/v1beta1/kubeflow/katib/rest.py | 5 +- .../v1beta1/kubeflow/katib/utils/utils.py | 2 +- sdk/python/v1beta1/setup.py | 1 + test/e2e/v1beta1/hack/aws/argo_workflow.py | 1 - .../scripts/gh-actions/run-e2e-experiment.py | 13 ++-- .../earlystopping/test_medianstop_service.py | 9 ++- .../test_tfevent_metricscollector.py | 1 + test/unit/v1beta1/metricscollector/utils.py | 2 +- .../v1beta1/suggestion/test_darts_service.py | 10 +-- .../v1beta1/suggestion/test_enas_service.py | 4 +- .../suggestion/test_hyperband_service.py | 4 +- .../suggestion/test_hyperopt_service.py | 3 +- .../v1beta1/suggestion/test_optuna_service.py | 3 +- .../v1beta1/suggestion/test_skopt_service.py | 3 +- 107 files changed, 447 insertions(+), 281 deletions(-) create mode 100644 .github/workflows/pre-commit/action.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit/action.yaml b/.github/workflows/pre-commit/action.yaml new file mode 100644 index 00000000000..6095e0861f9 --- /dev/null +++ b/.github/workflows/pre-commit/action.yaml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [master] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..9dc0844a10e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,61 @@ +repos: + # other fast helpful checks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-json + # - id: end-of-file-fixer + # - id: trailing-whitespace + # exclude: ^manifests/gcp_marketplace/test/* + # - id: debug-statements + # - id: check-merge-conflict + # - id: name-tests-test + # - id: double-quote-string-fixer + # - id: no-commit-to-branch + # args: [--branch, master] + # required formatting jobs (run these last) + + # add comment "noqa" to ignore an import that should not be removed + # (e.g., for an import with desired side-effects) + # - repo: https://github.com/hadialqattan/pycln + # rev: v2.1.1 + # hooks: + # - id: pycln + # name: pycln + # language: python + # entry: pycln --all + - repo: https://github.com/pycqa/isort + rev: 5.11.5 + hooks: + - id: isort + name: isort + entry: isort --profile google + # - repo: https://github.com/pre-commit/mirrors-yapf + # rev: "v0.32.0" + # hooks: + # - id: yapf + # - repo: https://github.com/pycqa/docformatter + # rev: v1.4 + # hooks: + # - id: docformatter + # name: docformatter + # language: python + # entry: docformatter -i -r + # docformatter messes up certain sphinx link formatting. + # The kubernetes_platform/python docstrings are heavy on links, so ignore. + # exclude: (sdk/python/kfp/compiler/compiler_test.py|kubernetes_platform/python/) + + # Golang pre-submit hooks + # - repo: https://github.com/golangci/golangci-lint + # rev: v1.52.2 + # hooks: + # - id: golangci-lint + # name: golangci-lint + # description: Fast linters runner for Go. + # entry: golangci-lint run --new-from-rev HEAD --fix + # types: [go] + # language: golang + # require_serial: true + # pass_filenames: false \ No newline at end of file diff --git a/cmd/earlystopping/medianstop/v1beta1/main.py b/cmd/earlystopping/medianstop/v1beta1/main.py index 1fcae3ca013..240517a76c3 100644 --- a/cmd/earlystopping/medianstop/v1beta1/main.py +++ b/cmd/earlystopping/medianstop/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc -import time +from concurrent import futures import logging +import time + +import grpc + from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.earlystopping.v1beta1.medianstop.service import MedianStopService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6788" diff --git a/cmd/metricscollector/v1beta1/tfevent-metricscollector/main.py b/cmd/metricscollector/v1beta1/tfevent-metricscollector/main.py index 29c95849bff..0908d460a07 100644 --- a/cmd/metricscollector/v1beta1/tfevent-metricscollector/main.py +++ b/cmd/metricscollector/v1beta1/tfevent-metricscollector/main.py @@ -12,13 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc import argparse +from logging import getLogger +from logging import INFO +from logging import StreamHandler + import api_pb2 -from pns import WaitMainProcesses import const +import grpc +from pns import WaitMainProcesses from tfevent_loader import MetricsCollector -from logging import getLogger, StreamHandler, INFO timeout_in_seconds = 60 diff --git a/cmd/suggestion/hyperband/v1beta1/main.py b/cmd/suggestion/hyperband/v1beta1/main.py index e81ffaace2c..21dd46e4d9e 100644 --- a/cmd/suggestion/hyperband/v1beta1/main.py +++ b/cmd/suggestion/hyperband/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc +from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.hyperband.service import HyperbandService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/hyperopt/v1beta1/main.py b/cmd/suggestion/hyperopt/v1beta1/main.py index 567eedc3e13..c459d5b532c 100644 --- a/cmd/suggestion/hyperopt/v1beta1/main.py +++ b/cmd/suggestion/hyperopt/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc +from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.hyperopt.service import HyperoptService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/nas/darts/v1beta1/main.py b/cmd/suggestion/nas/darts/v1beta1/main.py index 730545ec3c3..a1926ad8326 100644 --- a/cmd/suggestion/nas/darts/v1beta1/main.py +++ b/cmd/suggestion/nas/darts/v1beta1/main.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.nas.darts.service import DartsService - _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/nas/enas/v1beta1/main.py b/cmd/suggestion/nas/enas/v1beta1/main.py index 31d4b703abb..62dda9c810c 100644 --- a/cmd/suggestion/nas/enas/v1beta1/main.py +++ b/cmd/suggestion/nas/enas/v1beta1/main.py @@ -12,15 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.nas.enas.service import EnasService - _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/optuna/v1beta1/main.py b/cmd/suggestion/optuna/v1beta1/main.py index 8a30d03cc3e..435933f4858 100644 --- a/cmd/suggestion/optuna/v1beta1/main.py +++ b/cmd/suggestion/optuna/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc +from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.optuna.service import OptunaService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/pbt/v1beta1/main.py b/cmd/suggestion/pbt/v1beta1/main.py index b5e7f56e880..9e5efb133a6 100644 --- a/cmd/suggestion/pbt/v1beta1/main.py +++ b/cmd/suggestion/pbt/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc +from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.pbt.service import PbtService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/cmd/suggestion/skopt/v1beta1/main.py b/cmd/suggestion/skopt/v1beta1/main.py index 2fd21812e98..55d6215529b 100644 --- a/cmd/suggestion/skopt/v1beta1/main.py +++ b/cmd/suggestion/skopt/v1beta1/main.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc +from concurrent import futures import time -from pkg.apis.manager.v1beta1.python import api_pb2_grpc + +import grpc + from pkg.apis.manager.health.python import health_pb2_grpc +from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.skopt.service import SkoptService -from concurrent import futures _ONE_DAY_IN_SECONDS = 60 * 60 * 24 DEFAULT_PORT = "0.0.0.0:6789" diff --git a/docs/release/changelog.py b/docs/release/changelog.py index 4a6f9d1d668..ad08c471361 100644 --- a/docs/release/changelog.py +++ b/docs/release/changelog.py @@ -1,6 +1,7 @@ -from github import Github import argparse +from github import Github + REPO_NAME = "kubeflow/katib" CHANGELOG_FILE = "CHANGELOG.md" diff --git a/examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py b/examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py index eb605a6626d..d5867fd6c4e 100644 --- a/examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py +++ b/examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py @@ -27,18 +27,17 @@ # Follow this guide to install MPIJob on your cluster: https://www.kubeflow.org/docs/components/training/mpi/ import kfp -import kfp.dsl as dsl from kfp import components - +import kfp.dsl as dsl from kubeflow.katib import ApiClient -from kubeflow.katib import V1beta1ExperimentSpec -from kubeflow.katib import V1beta1AlgorithmSpec from kubeflow.katib import V1beta1AlgorithmSetting +from kubeflow.katib import V1beta1AlgorithmSpec +from kubeflow.katib import V1beta1ExperimentSpec +from kubeflow.katib import V1beta1FeasibleSpace from kubeflow.katib import V1beta1ObjectiveSpec from kubeflow.katib import V1beta1ParameterSpec -from kubeflow.katib import V1beta1FeasibleSpace -from kubeflow.katib import V1beta1TrialTemplate from kubeflow.katib import V1beta1TrialParameterSpec +from kubeflow.katib import V1beta1TrialTemplate @dsl.pipeline( diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/architect.py b/examples/v1beta1/trial-images/darts-cnn-cifar10/architect.py index c449a6a1fe9..af54729f284 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/architect.py +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/architect.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import torch import copy +import torch + class Architect(): """" Architect controls architecture of cell by computing gradients of alphas diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/model.py b/examples/v1beta1/trial-images/darts-cnn-cifar10/model.py index dea7d43f84c..195c0f8f865 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/model.py +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/model.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from operations import FactorizedReduce +from operations import MixedOp +from operations import StdConv import torch import torch.nn as nn import torch.nn.functional as F -from operations import FactorizedReduce, StdConv, MixedOp class Cell(nn.Module): diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/operations.py b/examples/v1beta1/trial-images/darts-cnn-cifar10/operations.py index 86fd74f343e..c701742fa0f 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/operations.py +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/operations.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import torch.nn as nn import torch +import torch.nn as nn OPS = { 'none': lambda channels, stride: Zero(stride), diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py b/examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py index a9836d240cd..8afc37e27d7 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py @@ -13,17 +13,16 @@ # limitations under the License. -import torch.nn as nn - -import torch import argparse import json -import numpy as np -from model import NetworkCNN from architect import Architect -import utils +from model import NetworkCNN +import numpy as np from search_space import SearchSpace +import torch +import torch.nn as nn +import utils def main(): diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/search_space.py b/examples/v1beta1/trial-images/darts-cnn-cifar10/search_space.py index df255954858..3485f1a1ec5 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/search_space.py +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/search_space.py @@ -13,6 +13,7 @@ # limitations under the License. from collections import namedtuple + import torch diff --git a/examples/v1beta1/trial-images/enas-cnn-cifar10/ModelConstructor.py b/examples/v1beta1/trial-images/enas-cnn-cifar10/ModelConstructor.py index 2927a8d2f6c..5de068b1608 100644 --- a/examples/v1beta1/trial-images/enas-cnn-cifar10/ModelConstructor.py +++ b/examples/v1beta1/trial-images/enas-cnn-cifar10/ModelConstructor.py @@ -12,13 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np -from keras.models import Model -from keras import backend as K import json -from keras.layers import Input, Conv2D, ZeroPadding2D, concatenate, MaxPooling2D, \ - AveragePooling2D, Dense, Activation, BatchNormalization, GlobalAveragePooling2D, Dropout -from op_library import concat, conv, sp_conv, dw_conv, reduction + +from keras import backend as K +from keras.layers import Activation +from keras.layers import AveragePooling2D +from keras.layers import BatchNormalization +from keras.layers import concatenate +from keras.layers import Conv2D +from keras.layers import Dense +from keras.layers import Dropout +from keras.layers import GlobalAveragePooling2D +from keras.layers import Input +from keras.layers import MaxPooling2D +from keras.layers import ZeroPadding2D +from keras.models import Model +import numpy as np +from op_library import concat +from op_library import conv +from op_library import dw_conv +from op_library import reduction +from op_library import sp_conv class ModelConstructor(object): diff --git a/examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py b/examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py index b178c582034..f843594674d 100644 --- a/examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py +++ b/examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py @@ -12,13 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tensorflow import keras +import argparse + from keras.datasets import cifar10 from ModelConstructor import ModelConstructor -from tensorflow.keras.utils import to_categorical -from tensorflow.keras.layers import RandomFlip, RandomTranslation, Rescaling +from tensorflow import keras import tensorflow as tf -import argparse +from tensorflow.keras.layers import RandomFlip +from tensorflow.keras.layers import RandomTranslation +from tensorflow.keras.layers import Rescaling +from tensorflow.keras.utils import to_categorical if __name__ == "__main__": parser = argparse.ArgumentParser(description='TrainingContainer') diff --git a/examples/v1beta1/trial-images/enas-cnn-cifar10/op_library.py b/examples/v1beta1/trial-images/enas-cnn-cifar10/op_library.py index ab02ed4a7a0..7defaf38464 100644 --- a/examples/v1beta1/trial-images/enas-cnn-cifar10/op_library.py +++ b/examples/v1beta1/trial-images/enas-cnn-cifar10/op_library.py @@ -12,11 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np from keras import backend as K -from keras.layers import Input, Conv2D, ZeroPadding2D, concatenate, MaxPooling2D, \ - AveragePooling2D, Dense, Activation, BatchNormalization, GlobalAveragePooling2D, \ - SeparableConv2D, DepthwiseConv2D +from keras.layers import Activation +from keras.layers import AveragePooling2D +from keras.layers import BatchNormalization +from keras.layers import concatenate +from keras.layers import Conv2D +from keras.layers import Dense +from keras.layers import DepthwiseConv2D +from keras.layers import GlobalAveragePooling2D +from keras.layers import Input +from keras.layers import MaxPooling2D +from keras.layers import SeparableConv2D +from keras.layers import ZeroPadding2D +import numpy as np def concat(inputs): diff --git a/examples/v1beta1/trial-images/pytorch-mnist/mnist.py b/examples/v1beta1/trial-images/pytorch-mnist/mnist.py index aabf6cf1617..95611f5953d 100644 --- a/examples/v1beta1/trial-images/pytorch-mnist/mnist.py +++ b/examples/v1beta1/trial-images/pytorch-mnist/mnist.py @@ -19,12 +19,13 @@ import os import hypertune -from torchvision import datasets, transforms import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F import torch.optim as optim +from torchvision import datasets +from torchvision import transforms WORLD_SIZE = int(os.environ.get("WORLD_SIZE", 1)) diff --git a/examples/v1beta1/trial-images/simple-pbt/pbt_test.py b/examples/v1beta1/trial-images/simple-pbt/pbt_test.py index 55ef3deca95..6194cd21798 100644 --- a/examples/v1beta1/trial-images/simple-pbt/pbt_test.py +++ b/examples/v1beta1/trial-images/simple-pbt/pbt_test.py @@ -17,12 +17,13 @@ # limitations under the License. import argparse -import numpy as np import os import pickle import random import time +import numpy as np + # Ensure job runs for at least this long (secs) to allow metrics collector to # read PID correctly before cleanup _METRICS_COLLECTOR_SPAWN_LATENCY = 7 diff --git a/examples/v1beta1/trial-images/tf-mnist-with-summaries/mnist.py b/examples/v1beta1/trial-images/tf-mnist-with-summaries/mnist.py index 07666e839cf..fea1ed575f4 100644 --- a/examples/v1beta1/trial-images/tf-mnist-with-summaries/mnist.py +++ b/examples/v1beta1/trial-images/tf-mnist-with-summaries/mnist.py @@ -14,10 +14,12 @@ import argparse import os -import tensorflow as tf -from tensorflow.keras.layers import Dense, Flatten, Conv2D +import tensorflow as tf from tensorflow.keras import Model +from tensorflow.keras.layers import Conv2D +from tensorflow.keras.layers import Dense +from tensorflow.keras.layers import Flatten class MyModel(Model): diff --git a/pkg/apis/manager/health/python/health_pb2.py b/pkg/apis/manager/health/python/health_pb2.py index ef49555776d..531355026cb 100644 --- a/pkg/apis/manager/health/python/health_pb2.py +++ b/pkg/apis/manager/health/python/health_pb2.py @@ -2,12 +2,14 @@ # source: health.proto import sys + _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pb2 from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database -from google.protobuf import descriptor_pb2 + # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() diff --git a/pkg/apis/manager/health/python/health_pb2_grpc.py b/pkg/apis/manager/health/python/health_pb2_grpc.py index cdaeac5ffe2..ed2203ea8c7 100644 --- a/pkg/apis/manager/health/python/health_pb2_grpc.py +++ b/pkg/apis/manager/health/python/health_pb2_grpc.py @@ -1,6 +1,5 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc - import health_pb2 as health__pb2 diff --git a/pkg/apis/manager/v1beta1/python/api_pb2.py b/pkg/apis/manager/v1beta1/python/api_pb2.py index 25ae1931e65..bc8fd0f7957 100644 --- a/pkg/apis/manager/v1beta1/python/api_pb2.py +++ b/pkg/apis/manager/v1beta1/python/api_pb2.py @@ -2,13 +2,15 @@ # source: api.proto import sys + _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) -from google.protobuf.internal import enum_type_wrapper from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pb2 from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database -from google.protobuf import descriptor_pb2 +from google.protobuf.internal import enum_type_wrapper + # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() diff --git a/pkg/apis/manager/v1beta1/python/api_pb2_grpc.py b/pkg/apis/manager/v1beta1/python/api_pb2_grpc.py index 7d5cbf79006..23145d59e1b 100644 --- a/pkg/apis/manager/v1beta1/python/api_pb2_grpc.py +++ b/pkg/apis/manager/v1beta1/python/api_pb2_grpc.py @@ -1,7 +1,6 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc - import api_pb2 as api__pb2 +import grpc class DBManagerStub(object): diff --git a/pkg/earlystopping/v1beta1/medianstop/service.py b/pkg/earlystopping/v1beta1/medianstop/service.py index 384d04f3a57..c228d6f52ad 100644 --- a/pkg/earlystopping/v1beta1/medianstop/service.py +++ b/pkg/earlystopping/v1beta1/medianstop/service.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from datetime import datetime import logging -from kubernetes import client, config import multiprocessing -from datetime import datetime + import grpc +from kubernetes import client +from kubernetes import config from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc diff --git a/pkg/metricscollector/v1beta1/common/pns.py b/pkg/metricscollector/v1beta1/common/pns.py index 2cdeb376a90..86f5563bbec 100644 --- a/pkg/metricscollector/v1beta1/common/pns.py +++ b/pkg/metricscollector/v1beta1/common/pns.py @@ -13,10 +13,11 @@ # limitations under the License. import os -import psutil import sys import time + import const +import psutil def WaitMainProcesses(pool_interval, timout, wait_all, completed_marked_dir): diff --git a/pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py b/pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py index 6b1700ce532..931014d1c15 100644 --- a/pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py +++ b/pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py @@ -21,14 +21,20 @@ # Check TFJob example for more information: # https://github.com/kubeflow/katib/blob/master/examples/v1beta1/kubeflow-training-operator/tfjob-mnist-with-summaries.yaml#L16-L22 -import tensorflow as tf -from tensorboard.backend.event_processing.event_accumulator import EventAccumulator, TensorEvent -from tensorboard.backend.event_processing.tag_types import TENSORS -import os -import rfc3339 from datetime import datetime +from logging import getLogger +from logging import INFO +from logging import StreamHandler +import os + import api_pb2 -from logging import getLogger, StreamHandler, INFO +import rfc3339 +from tensorboard.backend.event_processing.event_accumulator import \ + EventAccumulator +from tensorboard.backend.event_processing.event_accumulator import TensorEvent +from tensorboard.backend.event_processing.tag_types import TENSORS +import tensorflow as tf + from pkg.metricscollector.v1beta1.common import const diff --git a/pkg/suggestion/v1beta1/hyperband/parsing_util.py b/pkg/suggestion/v1beta1/hyperband/parsing_util.py index d5dd6f0d111..4136fe7246b 100644 --- a/pkg/suggestion/v1beta1/hyperband/parsing_util.py +++ b/pkg/suggestion/v1beta1/hyperband/parsing_util.py @@ -18,8 +18,10 @@ suggestion generation algorithms. """ from collections.abc import Iterable -from pkg.apis.manager.v1beta1.python import api_pb2 + import numpy as np + +from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.suggestion.v1beta1.hyperband.parameter import ParameterConfig diff --git a/pkg/suggestion/v1beta1/hyperband/service.py b/pkg/suggestion/v1beta1/hyperband/service.py index 1350d32aa83..50919826d0a 100644 --- a/pkg/suggestion/v1beta1/hyperband/service.py +++ b/pkg/suggestion/v1beta1/hyperband/service.py @@ -12,11 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging +from logging import DEBUG +from logging import getLogger +from logging import StreamHandler import math import traceback + import grpc -import logging -from logging import getLogger, StreamHandler, DEBUG from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc diff --git a/pkg/suggestion/v1beta1/hyperopt/base_service.py b/pkg/suggestion/v1beta1/hyperopt/base_service.py index e4f8174d051..894a98637bf 100644 --- a/pkg/suggestion/v1beta1/hyperopt/base_service.py +++ b/pkg/suggestion/v1beta1/hyperopt/base_service.py @@ -12,11 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging + import hyperopt import numpy as np -import logging -from pkg.suggestion.v1beta1.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL +from pkg.suggestion.v1beta1.internal.constant import CATEGORICAL +from pkg.suggestion.v1beta1.internal.constant import DISCRETE +from pkg.suggestion.v1beta1.internal.constant import DOUBLE +from pkg.suggestion.v1beta1.internal.constant import INTEGER +from pkg.suggestion.v1beta1.internal.constant import MAX_GOAL from pkg.suggestion.v1beta1.internal.trial import Assignment logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/hyperopt/service.py b/pkg/suggestion/v1beta1/hyperopt/service.py index 854f2447131..d3a9cdfe7c5 100644 --- a/pkg/suggestion/v1beta1/hyperopt/service.py +++ b/pkg/suggestion/v1beta1/hyperopt/service.py @@ -13,15 +13,17 @@ # limitations under the License. import logging + import grpc from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc - -from pkg.suggestion.v1beta1.internal.search_space import HyperParameterSearchSpace -from pkg.suggestion.v1beta1.internal.trial import Trial, Assignment from pkg.suggestion.v1beta1.hyperopt.base_service import BaseHyperoptService from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer +from pkg.suggestion.v1beta1.internal.search_space import \ + HyperParameterSearchSpace +from pkg.suggestion.v1beta1.internal.trial import Assignment +from pkg.suggestion.v1beta1.internal.trial import Trial logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/internal/search_space.py b/pkg/suggestion/v1beta1/internal/search_space.py index 25d68761805..d50955810e5 100644 --- a/pkg/suggestion/v1beta1/internal/search_space.py +++ b/pkg/suggestion/v1beta1/internal/search_space.py @@ -13,10 +13,14 @@ # limitations under the License. import logging + import numpy as np from pkg.apis.manager.v1beta1.python import api_pb2 as api -from pkg.suggestion.v1beta1.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE +from pkg.suggestion.v1beta1.internal.constant import CATEGORICAL +from pkg.suggestion.v1beta1.internal.constant import DISCRETE +from pkg.suggestion.v1beta1.internal.constant import DOUBLE +from pkg.suggestion.v1beta1.internal.constant import INTEGER import pkg.suggestion.v1beta1.internal.constant as constant logging.basicConfig(level=logging.DEBUG) diff --git a/pkg/suggestion/v1beta1/internal/trial.py b/pkg/suggestion/v1beta1/internal/trial.py index c868de24bd7..906617d0c0f 100644 --- a/pkg/suggestion/v1beta1/internal/trial.py +++ b/pkg/suggestion/v1beta1/internal/trial.py @@ -13,8 +13,8 @@ # limitations under the License. import logging -from pkg.apis.manager.v1beta1.python import api_pb2 as api +from pkg.apis.manager.v1beta1.python import api_pb2 as api logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/nas/darts/service.py b/pkg/suggestion/v1beta1/nas/darts/service.py index 2ab92c3d75a..55e7751a8f3 100644 --- a/pkg/suggestion/v1beta1/nas/darts/service.py +++ b/pkg/suggestion/v1beta1/nas/darts/service.py @@ -12,14 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging -from logging import getLogger, StreamHandler, INFO import json +import logging +from logging import getLogger +from logging import INFO +from logging import StreamHandler + import grpc -from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc +from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer from pkg.suggestion.v1beta1.nas.common.validation import validate_operations diff --git a/pkg/suggestion/v1beta1/nas/enas/Controller.py b/pkg/suggestion/v1beta1/nas/enas/Controller.py index a5745af225c..12a43a32c56 100644 --- a/pkg/suggestion/v1beta1/nas/enas/Controller.py +++ b/pkg/suggestion/v1beta1/nas/enas/Controller.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import tensorflow as tf import numpy as np +import tensorflow as tf class Controller(object): diff --git a/pkg/suggestion/v1beta1/nas/enas/Operation.py b/pkg/suggestion/v1beta1/nas/enas/Operation.py index d078b4f4332..3fe94df792e 100644 --- a/pkg/suggestion/v1beta1/nas/enas/Operation.py +++ b/pkg/suggestion/v1beta1/nas/enas/Operation.py @@ -13,7 +13,9 @@ # limitations under the License. import itertools + import numpy as np + from pkg.apis.manager.v1beta1.python import api_pb2 diff --git a/pkg/suggestion/v1beta1/nas/enas/service.py b/pkg/suggestion/v1beta1/nas/enas/service.py index 9477ec115ba..c0e7970f127 100644 --- a/pkg/suggestion/v1beta1/nas/enas/service.py +++ b/pkg/suggestion/v1beta1/nas/enas/service.py @@ -12,21 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging -from logging import getLogger, StreamHandler, INFO import json +import logging +from logging import getLogger +from logging import INFO +from logging import StreamHandler import os -import tensorflow as tf + import grpc +import tensorflow as tf from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc -from pkg.suggestion.v1beta1.nas.enas.Controller import Controller -from pkg.suggestion.v1beta1.nas.enas.Operation import SearchSpace -from pkg.suggestion.v1beta1.nas.enas.AlgorithmSettings import ( - parseAlgorithmSettings, algorithmSettingsValidator, enableNoneSettingsList) from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer from pkg.suggestion.v1beta1.nas.common.validation import validate_operations +from pkg.suggestion.v1beta1.nas.enas.AlgorithmSettings import \ + algorithmSettingsValidator +from pkg.suggestion.v1beta1.nas.enas.AlgorithmSettings import \ + enableNoneSettingsList +from pkg.suggestion.v1beta1.nas.enas.AlgorithmSettings import \ + parseAlgorithmSettings +from pkg.suggestion.v1beta1.nas.enas.Controller import Controller +from pkg.suggestion.v1beta1.nas.enas.Operation import SearchSpace class EnasExperiment: diff --git a/pkg/suggestion/v1beta1/optuna/base_service.py b/pkg/suggestion/v1beta1/optuna/base_service.py index c4c742514f2..ce790173024 100644 --- a/pkg/suggestion/v1beta1/optuna/base_service.py +++ b/pkg/suggestion/v1beta1/optuna/base_service.py @@ -12,12 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import optuna from collections import defaultdict -from pkg.suggestion.v1beta1.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL +import optuna + +from pkg.suggestion.v1beta1.internal.constant import CATEGORICAL +from pkg.suggestion.v1beta1.internal.constant import DISCRETE +from pkg.suggestion.v1beta1.internal.constant import DOUBLE +from pkg.suggestion.v1beta1.internal.constant import INTEGER +from pkg.suggestion.v1beta1.internal.constant import MAX_GOAL +from pkg.suggestion.v1beta1.internal.search_space import \ + HyperParameterSearchSpace from pkg.suggestion.v1beta1.internal.trial import Assignment -from pkg.suggestion.v1beta1.internal.search_space import HyperParameterSearchSpace class BaseOptunaService(object): diff --git a/pkg/suggestion/v1beta1/optuna/service.py b/pkg/suggestion/v1beta1/optuna/service.py index f5bc5a4e875..a99d0043676 100644 --- a/pkg/suggestion/v1beta1/optuna/service.py +++ b/pkg/suggestion/v1beta1/optuna/service.py @@ -12,17 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools +import logging import threading + import grpc -import logging -import itertools from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc -from pkg.suggestion.v1beta1.internal.search_space import HyperParameterSearchSpace -from pkg.suggestion.v1beta1.internal.trial import Trial, Assignment -from pkg.suggestion.v1beta1.optuna.base_service import BaseOptunaService from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer +from pkg.suggestion.v1beta1.internal.search_space import \ + HyperParameterSearchSpace +from pkg.suggestion.v1beta1.internal.trial import Assignment +from pkg.suggestion.v1beta1.internal.trial import Trial +from pkg.suggestion.v1beta1.optuna.base_service import BaseOptunaService logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/pbt/service.py b/pkg/suggestion/v1beta1/pbt/service.py index bab92fbcc7b..38087786e7a 100644 --- a/pkg/suggestion/v1beta1/pbt/service.py +++ b/pkg/suggestion/v1beta1/pbt/service.py @@ -12,22 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc import logging -import numpy as np import os import shutil import uuid +import grpc +import numpy as np + from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc -from pkg.suggestion.v1beta1.internal.search_space import ( - HyperParameter, - HyperParameterSearchSpace, -) -import pkg.suggestion.v1beta1.internal.constant as constant -from pkg.suggestion.v1beta1.internal.trial import Trial, Assignment from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer +import pkg.suggestion.v1beta1.internal.constant as constant +from pkg.suggestion.v1beta1.internal.search_space import HyperParameter +from pkg.suggestion.v1beta1.internal.search_space import \ + HyperParameterSearchSpace +from pkg.suggestion.v1beta1.internal.trial import Assignment +from pkg.suggestion.v1beta1.internal.trial import Trial logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/skopt/base_service.py b/pkg/suggestion/v1beta1/skopt/base_service.py index c907f76d816..434c3a8b908 100644 --- a/pkg/suggestion/v1beta1/skopt/base_service.py +++ b/pkg/suggestion/v1beta1/skopt/base_service.py @@ -14,9 +14,14 @@ import datetime import logging + import skopt -from pkg.suggestion.v1beta1.internal.constant import INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL +from pkg.suggestion.v1beta1.internal.constant import CATEGORICAL +from pkg.suggestion.v1beta1.internal.constant import DISCRETE +from pkg.suggestion.v1beta1.internal.constant import DOUBLE +from pkg.suggestion.v1beta1.internal.constant import INTEGER +from pkg.suggestion.v1beta1.internal.constant import MAX_GOAL from pkg.suggestion.v1beta1.internal.trial import Assignment logger = logging.getLogger(__name__) diff --git a/pkg/suggestion/v1beta1/skopt/service.py b/pkg/suggestion/v1beta1/skopt/service.py index d069ecb706c..4ac0041866f 100644 --- a/pkg/suggestion/v1beta1/skopt/service.py +++ b/pkg/suggestion/v1beta1/skopt/service.py @@ -19,8 +19,10 @@ from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.apis.manager.v1beta1.python import api_pb2_grpc from pkg.suggestion.v1beta1.internal.base_health_service import HealthServicer -from pkg.suggestion.v1beta1.internal.search_space import HyperParameterSearchSpace -from pkg.suggestion.v1beta1.internal.trial import Trial, Assignment +from pkg.suggestion.v1beta1.internal.search_space import \ + HyperParameterSearchSpace +from pkg.suggestion.v1beta1.internal.trial import Assignment +from pkg.suggestion.v1beta1.internal.trial import Trial from pkg.suggestion.v1beta1.skopt.base_service import BaseSkoptService logger = logging.getLogger(__name__) diff --git a/sdk/python/v1beta1/kubeflow/katib/__init__.py b/sdk/python/v1beta1/kubeflow/katib/__init__.py index a949c8567e1..bbeddb61c95 100644 --- a/sdk/python/v1beta1/kubeflow/katib/__init__.py +++ b/sdk/python/v1beta1/kubeflow/katib/__init__.py @@ -18,63 +18,76 @@ # import apis into sdk package +# Import Katib API client. +from kubeflow.katib.api.katib_client import KatibClient +# Import Katib helper functions. +import kubeflow.katib.api.search as search # import ApiClient from kubeflow.katib.api_client import ApiClient from kubeflow.katib.configuration import Configuration -from kubeflow.katib.exceptions import OpenApiException +# Import Katib helper constants. +from kubeflow.katib.constants.constants import BASE_IMAGE_MXNET +from kubeflow.katib.constants.constants import BASE_IMAGE_PYTORCH +from kubeflow.katib.constants.constants import BASE_IMAGE_TENSORFLOW +from kubeflow.katib.constants.constants import BASE_IMAGE_TENSORFLOW_GPU +from kubeflow.katib.exceptions import ApiException +from kubeflow.katib.exceptions import ApiKeyError from kubeflow.katib.exceptions import ApiTypeError from kubeflow.katib.exceptions import ApiValueError -from kubeflow.katib.exceptions import ApiKeyError -from kubeflow.katib.exceptions import ApiException +from kubeflow.katib.exceptions import OpenApiException # import models into sdk package -from kubeflow.katib.models.v1beta1_algorithm_setting import V1beta1AlgorithmSetting +from kubeflow.katib.models.v1beta1_algorithm_setting import \ + V1beta1AlgorithmSetting from kubeflow.katib.models.v1beta1_algorithm_spec import V1beta1AlgorithmSpec from kubeflow.katib.models.v1beta1_collector_spec import V1beta1CollectorSpec -from kubeflow.katib.models.v1beta1_config_map_source import V1beta1ConfigMapSource -from kubeflow.katib.models.v1beta1_early_stopping_rule import V1beta1EarlyStoppingRule -from kubeflow.katib.models.v1beta1_early_stopping_setting import V1beta1EarlyStoppingSetting -from kubeflow.katib.models.v1beta1_early_stopping_spec import V1beta1EarlyStoppingSpec +from kubeflow.katib.models.v1beta1_config_map_source import \ + V1beta1ConfigMapSource +from kubeflow.katib.models.v1beta1_early_stopping_rule import \ + V1beta1EarlyStoppingRule +from kubeflow.katib.models.v1beta1_early_stopping_setting import \ + V1beta1EarlyStoppingSetting +from kubeflow.katib.models.v1beta1_early_stopping_spec import \ + V1beta1EarlyStoppingSpec from kubeflow.katib.models.v1beta1_experiment import V1beta1Experiment -from kubeflow.katib.models.v1beta1_experiment_condition import V1beta1ExperimentCondition +from kubeflow.katib.models.v1beta1_experiment_condition import \ + V1beta1ExperimentCondition from kubeflow.katib.models.v1beta1_experiment_list import V1beta1ExperimentList from kubeflow.katib.models.v1beta1_experiment_spec import V1beta1ExperimentSpec -from kubeflow.katib.models.v1beta1_experiment_status import V1beta1ExperimentStatus +from kubeflow.katib.models.v1beta1_experiment_status import \ + V1beta1ExperimentStatus from kubeflow.katib.models.v1beta1_feasible_space import V1beta1FeasibleSpace -from kubeflow.katib.models.v1beta1_file_system_path import V1beta1FileSystemPath +from kubeflow.katib.models.v1beta1_file_system_path import \ + V1beta1FileSystemPath from kubeflow.katib.models.v1beta1_filter_spec import V1beta1FilterSpec from kubeflow.katib.models.v1beta1_graph_config import V1beta1GraphConfig from kubeflow.katib.models.v1beta1_metric import V1beta1Metric from kubeflow.katib.models.v1beta1_metric_strategy import V1beta1MetricStrategy -from kubeflow.katib.models.v1beta1_metrics_collector_spec import V1beta1MetricsCollectorSpec +from kubeflow.katib.models.v1beta1_metrics_collector_spec import \ + V1beta1MetricsCollectorSpec from kubeflow.katib.models.v1beta1_nas_config import V1beta1NasConfig from kubeflow.katib.models.v1beta1_objective_spec import V1beta1ObjectiveSpec from kubeflow.katib.models.v1beta1_observation import V1beta1Observation from kubeflow.katib.models.v1beta1_operation import V1beta1Operation from kubeflow.katib.models.v1beta1_optimal_trial import V1beta1OptimalTrial -from kubeflow.katib.models.v1beta1_parameter_assignment import V1beta1ParameterAssignment +from kubeflow.katib.models.v1beta1_parameter_assignment import \ + V1beta1ParameterAssignment from kubeflow.katib.models.v1beta1_parameter_spec import V1beta1ParameterSpec from kubeflow.katib.models.v1beta1_source_spec import V1beta1SourceSpec from kubeflow.katib.models.v1beta1_suggestion import V1beta1Suggestion -from kubeflow.katib.models.v1beta1_suggestion_condition import V1beta1SuggestionCondition +from kubeflow.katib.models.v1beta1_suggestion_condition import \ + V1beta1SuggestionCondition from kubeflow.katib.models.v1beta1_suggestion_list import V1beta1SuggestionList from kubeflow.katib.models.v1beta1_suggestion_spec import V1beta1SuggestionSpec -from kubeflow.katib.models.v1beta1_suggestion_status import V1beta1SuggestionStatus +from kubeflow.katib.models.v1beta1_suggestion_status import \ + V1beta1SuggestionStatus from kubeflow.katib.models.v1beta1_trial import V1beta1Trial -from kubeflow.katib.models.v1beta1_trial_assignment import V1beta1TrialAssignment +from kubeflow.katib.models.v1beta1_trial_assignment import \ + V1beta1TrialAssignment from kubeflow.katib.models.v1beta1_trial_condition import V1beta1TrialCondition from kubeflow.katib.models.v1beta1_trial_list import V1beta1TrialList -from kubeflow.katib.models.v1beta1_trial_parameter_spec import V1beta1TrialParameterSpec +from kubeflow.katib.models.v1beta1_trial_parameter_spec import \ + V1beta1TrialParameterSpec from kubeflow.katib.models.v1beta1_trial_source import V1beta1TrialSource from kubeflow.katib.models.v1beta1_trial_spec import V1beta1TrialSpec from kubeflow.katib.models.v1beta1_trial_status import V1beta1TrialStatus from kubeflow.katib.models.v1beta1_trial_template import V1beta1TrialTemplate - -# Import Katib API client. -from kubeflow.katib.api.katib_client import KatibClient -# Import Katib helper functions. -import kubeflow.katib.api.search as search -# Import Katib helper constants. -from kubeflow.katib.constants.constants import BASE_IMAGE_TENSORFLOW -from kubeflow.katib.constants.constants import BASE_IMAGE_TENSORFLOW_GPU -from kubeflow.katib.constants.constants import BASE_IMAGE_PYTORCH -from kubeflow.katib.constants.constants import BASE_IMAGE_MXNET diff --git a/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py b/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py index 8be9e52f6da..170842e4fa9 100644 --- a/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py +++ b/sdk/python/v1beta1/kubeflow/katib/api/katib_client.py @@ -19,12 +19,13 @@ from typing import Any, Callable, Dict, List, Optional, Union import grpc -import kubeflow.katib.katib_api_pb2 as katib_api_pb2 from kubeflow.katib import models from kubeflow.katib.api_client import ApiClient from kubeflow.katib.constants import constants +import kubeflow.katib.katib_api_pb2 as katib_api_pb2 from kubeflow.katib.utils import utils -from kubernetes import client, config +from kubernetes import client +from kubernetes import config class KatibClient(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/api/search.py b/sdk/python/v1beta1/kubeflow/katib/api/search.py index 83204c3d43f..12a9ffcddcd 100644 --- a/sdk/python/v1beta1/kubeflow/katib/api/search.py +++ b/sdk/python/v1beta1/kubeflow/katib/api/search.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from kubeflow.katib import models from typing import List +from kubeflow.katib import models + def double(min: float, max: float, step: float = None): """Sample a float value uniformly between `min` and `max`. diff --git a/sdk/python/v1beta1/kubeflow/katib/api_client.py b/sdk/python/v1beta1/kubeflow/katib/api_client.py index 0a77d18c53d..8db4b17abff 100644 --- a/sdk/python/v1beta1/kubeflow/katib/api_client.py +++ b/sdk/python/v1beta1/kubeflow/katib/api_client.py @@ -12,7 +12,6 @@ import atexit import datetime -from dateutil.parser import parse import json import mimetypes from multiprocessing.pool import ThreadPool @@ -20,15 +19,16 @@ import re import tempfile +from dateutil.parser import parse +from kubeflow.katib import rest +from kubeflow.katib.configuration import Configuration +from kubeflow.katib.exceptions import ApiException +from kubeflow.katib.exceptions import ApiValueError +import kubeflow.katib.models # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import quote -from kubeflow.katib.configuration import Configuration -import kubeflow.katib.models -from kubeflow.katib import rest -from kubeflow.katib.exceptions import ApiValueError, ApiException - class ApiClient(object): """Generic API client for OpenAPI client library builds. diff --git a/sdk/python/v1beta1/kubeflow/katib/configuration.py b/sdk/python/v1beta1/kubeflow/katib/configuration.py index 2c01b00e3c1..72104a22161 100644 --- a/sdk/python/v1beta1/kubeflow/katib/configuration.py +++ b/sdk/python/v1beta1/kubeflow/katib/configuration.py @@ -16,10 +16,10 @@ import logging import multiprocessing import sys -import urllib3 import six from six.moves import http_client as httplib +import urllib3 class Configuration(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/__init__.py b/sdk/python/v1beta1/kubeflow/katib/models/__init__.py index 3fe8435a9c5..1f71a32ee2b 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/__init__.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/__init__.py @@ -14,47 +14,60 @@ from __future__ import absolute_import # import models into model package -from kubeflow.katib.models.v1beta1_algorithm_setting import V1beta1AlgorithmSetting +from kubeflow.katib.models.v1beta1_algorithm_setting import \ + V1beta1AlgorithmSetting from kubeflow.katib.models.v1beta1_algorithm_spec import V1beta1AlgorithmSpec from kubeflow.katib.models.v1beta1_collector_spec import V1beta1CollectorSpec -from kubeflow.katib.models.v1beta1_config_map_source import V1beta1ConfigMapSource -from kubeflow.katib.models.v1beta1_early_stopping_rule import V1beta1EarlyStoppingRule -from kubeflow.katib.models.v1beta1_early_stopping_setting import V1beta1EarlyStoppingSetting -from kubeflow.katib.models.v1beta1_early_stopping_spec import V1beta1EarlyStoppingSpec +from kubeflow.katib.models.v1beta1_config_map_source import \ + V1beta1ConfigMapSource +from kubeflow.katib.models.v1beta1_early_stopping_rule import \ + V1beta1EarlyStoppingRule +from kubeflow.katib.models.v1beta1_early_stopping_setting import \ + V1beta1EarlyStoppingSetting +from kubeflow.katib.models.v1beta1_early_stopping_spec import \ + V1beta1EarlyStoppingSpec from kubeflow.katib.models.v1beta1_experiment import V1beta1Experiment -from kubeflow.katib.models.v1beta1_experiment_condition import V1beta1ExperimentCondition +from kubeflow.katib.models.v1beta1_experiment_condition import \ + V1beta1ExperimentCondition from kubeflow.katib.models.v1beta1_experiment_list import V1beta1ExperimentList from kubeflow.katib.models.v1beta1_experiment_spec import V1beta1ExperimentSpec -from kubeflow.katib.models.v1beta1_experiment_status import V1beta1ExperimentStatus +from kubeflow.katib.models.v1beta1_experiment_status import \ + V1beta1ExperimentStatus from kubeflow.katib.models.v1beta1_feasible_space import V1beta1FeasibleSpace -from kubeflow.katib.models.v1beta1_file_system_path import V1beta1FileSystemPath +from kubeflow.katib.models.v1beta1_file_system_path import \ + V1beta1FileSystemPath from kubeflow.katib.models.v1beta1_filter_spec import V1beta1FilterSpec from kubeflow.katib.models.v1beta1_graph_config import V1beta1GraphConfig from kubeflow.katib.models.v1beta1_metric import V1beta1Metric from kubeflow.katib.models.v1beta1_metric_strategy import V1beta1MetricStrategy -from kubeflow.katib.models.v1beta1_metrics_collector_spec import V1beta1MetricsCollectorSpec +from kubeflow.katib.models.v1beta1_metrics_collector_spec import \ + V1beta1MetricsCollectorSpec from kubeflow.katib.models.v1beta1_nas_config import V1beta1NasConfig from kubeflow.katib.models.v1beta1_objective_spec import V1beta1ObjectiveSpec from kubeflow.katib.models.v1beta1_observation import V1beta1Observation from kubeflow.katib.models.v1beta1_operation import V1beta1Operation from kubeflow.katib.models.v1beta1_optimal_trial import V1beta1OptimalTrial -from kubeflow.katib.models.v1beta1_parameter_assignment import V1beta1ParameterAssignment +from kubeflow.katib.models.v1beta1_parameter_assignment import \ + V1beta1ParameterAssignment from kubeflow.katib.models.v1beta1_parameter_spec import V1beta1ParameterSpec from kubeflow.katib.models.v1beta1_source_spec import V1beta1SourceSpec from kubeflow.katib.models.v1beta1_suggestion import V1beta1Suggestion -from kubeflow.katib.models.v1beta1_suggestion_condition import V1beta1SuggestionCondition +from kubeflow.katib.models.v1beta1_suggestion_condition import \ + V1beta1SuggestionCondition from kubeflow.katib.models.v1beta1_suggestion_list import V1beta1SuggestionList from kubeflow.katib.models.v1beta1_suggestion_spec import V1beta1SuggestionSpec -from kubeflow.katib.models.v1beta1_suggestion_status import V1beta1SuggestionStatus +from kubeflow.katib.models.v1beta1_suggestion_status import \ + V1beta1SuggestionStatus from kubeflow.katib.models.v1beta1_trial import V1beta1Trial -from kubeflow.katib.models.v1beta1_trial_assignment import V1beta1TrialAssignment +from kubeflow.katib.models.v1beta1_trial_assignment import \ + V1beta1TrialAssignment from kubeflow.katib.models.v1beta1_trial_condition import V1beta1TrialCondition from kubeflow.katib.models.v1beta1_trial_list import V1beta1TrialList -from kubeflow.katib.models.v1beta1_trial_parameter_spec import V1beta1TrialParameterSpec +from kubeflow.katib.models.v1beta1_trial_parameter_spec import \ + V1beta1TrialParameterSpec from kubeflow.katib.models.v1beta1_trial_source import V1beta1TrialSource from kubeflow.katib.models.v1beta1_trial_spec import V1beta1TrialSpec from kubeflow.katib.models.v1beta1_trial_status import V1beta1TrialStatus from kubeflow.katib.models.v1beta1_trial_template import V1beta1TrialTemplate - # Import Kubernetes models. from kubernetes.client import * diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_setting.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_setting.py index 0062568e10c..a6e52997f37 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_setting.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_setting.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1AlgorithmSetting(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_spec.py index c14f3de79fb..c961d818b82 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_algorithm_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1AlgorithmSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_collector_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_collector_spec.py index 21fff58bb59..4ff1a97d431 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_collector_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_collector_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1CollectorSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_config_map_source.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_config_map_source.py index 57ee65c0608..9b3d78e46f7 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_config_map_source.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_config_map_source.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ConfigMapSource(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_rule.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_rule.py index 55e0e7702a5..773560a6a0e 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_rule.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_rule.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1EarlyStoppingRule(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_setting.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_setting.py index 634c5f53b27..a4322dabb13 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_setting.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_setting.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1EarlyStoppingSetting(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_spec.py index c192019b3bb..f7339b77685 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_early_stopping_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1EarlyStoppingSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment.py index 7da73ead88c..8d4d0f1b0a5 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Experiment(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_condition.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_condition.py index 041396abd20..545789e524b 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_condition.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_condition.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ExperimentCondition(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_list.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_list.py index 58746127f83..dc63bdec9d6 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_list.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_list.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ExperimentList(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_spec.py index 0846c8f4d27..b78db8ffec1 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ExperimentSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_status.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_status.py index 5155275329d..624cf1c4151 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_status.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_experiment_status.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ExperimentStatus(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_feasible_space.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_feasible_space.py index 248318e80ed..7b7932a01fd 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_feasible_space.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_feasible_space.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1FeasibleSpace(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_file_system_path.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_file_system_path.py index 95d12423868..45e5991eda5 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_file_system_path.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_file_system_path.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1FileSystemPath(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_filter_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_filter_spec.py index d8a6ec1e3f4..a3a703cbcb7 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_filter_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_filter_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1FilterSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_graph_config.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_graph_config.py index b74a8a1dae7..37904d6e5d8 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_graph_config.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_graph_config.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1GraphConfig(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric.py index 2c2f2ed26d8..053e39cf473 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Metric(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric_strategy.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric_strategy.py index 26897a1e605..dd3663225da 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric_strategy.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metric_strategy.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1MetricStrategy(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metrics_collector_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metrics_collector_spec.py index e4b75729098..08980ed0613 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metrics_collector_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_metrics_collector_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1MetricsCollectorSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_nas_config.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_nas_config.py index dbc00690b16..d8d4e53275f 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_nas_config.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_nas_config.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1NasConfig(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_objective_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_objective_spec.py index e18dac8a15f..35e2e7ac649 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_objective_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_objective_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ObjectiveSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_observation.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_observation.py index 82805643ee5..fd1274bcf93 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_observation.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_observation.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Observation(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_operation.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_operation.py index e3fe6b577ef..c41a48cd811 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_operation.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_operation.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Operation(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_optimal_trial.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_optimal_trial.py index 3cde7d4f115..c160dd6db9c 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_optimal_trial.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_optimal_trial.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1OptimalTrial(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_assignment.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_assignment.py index 74e26bbaa11..e4d752cb114 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_assignment.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_assignment.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ParameterAssignment(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_spec.py index 34f671b5638..ae148d44705 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_parameter_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1ParameterSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_source_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_source_spec.py index e4ce84644c6..a4958284de4 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_source_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_source_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1SourceSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion.py index 573fa158b5e..0ea0a90fd70 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Suggestion(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_condition.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_condition.py index 7ad25f69bcc..fe07f0f77c8 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_condition.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_condition.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1SuggestionCondition(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_list.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_list.py index 407571cda7f..fff9e99fd97 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_list.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_list.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1SuggestionList(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_spec.py index 6d4cd1b20b6..32cd6999e85 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1SuggestionSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_status.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_status.py index 8281ba51c48..bc26cae2935 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_status.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_suggestion_status.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1SuggestionStatus(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial.py index d66a0936050..c7284583f88 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1Trial(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_assignment.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_assignment.py index a106534e844..bb6c8fea193 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_assignment.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_assignment.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialAssignment(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_condition.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_condition.py index 7ae8e151337..f46a48cd79a 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_condition.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_condition.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialCondition(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_list.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_list.py index 59a2bcca352..00d2bf85a97 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_list.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_list.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialList(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_parameter_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_parameter_spec.py index 2bdb94ac294..a82e1562213 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_parameter_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_parameter_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialParameterSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_source.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_source.py index 3bbff419358..79f3c00f29d 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_source.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_source.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialSource(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_spec.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_spec.py index ba9e6b8fabc..9676cb0cafb 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_spec.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_spec.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialSpec(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_status.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_status.py index cd79b217368..91776d4cbfc 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_status.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_status.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialStatus(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_template.py b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_template.py index 200060257b6..a3dc8149fa2 100644 --- a/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_template.py +++ b/sdk/python/v1beta1/kubeflow/katib/models/v1beta1_trial_template.py @@ -13,9 +13,8 @@ import pprint import re # noqa: F401 -import six - from kubeflow.katib.configuration import Configuration +import six class V1beta1TrialTemplate(object): diff --git a/sdk/python/v1beta1/kubeflow/katib/rest.py b/sdk/python/v1beta1/kubeflow/katib/rest.py index 218d4807ef9..63d657cb2bb 100644 --- a/sdk/python/v1beta1/kubeflow/katib/rest.py +++ b/sdk/python/v1beta1/kubeflow/katib/rest.py @@ -19,14 +19,13 @@ import ssl import certifi +from kubeflow.katib.exceptions import ApiException +from kubeflow.katib.exceptions import ApiValueError # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode import urllib3 -from kubeflow.katib.exceptions import ApiException, ApiValueError - - logger = logging.getLogger(__name__) diff --git a/sdk/python/v1beta1/kubeflow/katib/utils/utils.py b/sdk/python/v1beta1/kubeflow/katib/utils/utils.py index 97c46772611..4cb78e8d673 100644 --- a/sdk/python/v1beta1/kubeflow/katib/utils/utils.py +++ b/sdk/python/v1beta1/kubeflow/katib/utils/utils.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import inspect import json import os import textwrap from typing import Callable -import inspect from kubeflow.katib import models from kubeflow.katib.constants import constants diff --git a/sdk/python/v1beta1/setup.py b/sdk/python/v1beta1/setup.py index 39a4f0e2372..3de8554fa6d 100644 --- a/sdk/python/v1beta1/setup.py +++ b/sdk/python/v1beta1/setup.py @@ -14,6 +14,7 @@ import os import shutil + import setuptools REQUIRES = [ diff --git a/test/e2e/v1beta1/hack/aws/argo_workflow.py b/test/e2e/v1beta1/hack/aws/argo_workflow.py index b38b5beeb78..12edf283e7a 100644 --- a/test/e2e/v1beta1/hack/aws/argo_workflow.py +++ b/test/e2e/v1beta1/hack/aws/argo_workflow.py @@ -16,7 +16,6 @@ from kubeflow.testing import argo_build_util - # Main worker image to execute Workflow. IMAGE_WORKER = "public.ecr.aws/j1r0q0g6/kubeflow-testing:latest" # Kaniko image to build Katib images. diff --git a/test/e2e/v1beta1/scripts/gh-actions/run-e2e-experiment.py b/test/e2e/v1beta1/scripts/gh-actions/run-e2e-experiment.py index abd08ccec00..26ef2e9f6e2 100644 --- a/test/e2e/v1beta1/scripts/gh-actions/run-e2e-experiment.py +++ b/test/e2e/v1beta1/scripts/gh-actions/run-e2e-experiment.py @@ -1,11 +1,14 @@ import argparse -import yaml -import time import logging -from kubernetes import client -from kubeflow.katib import ApiClient, KatibClient, models -from kubeflow.katib.utils.utils import FakeResponse +import time + +from kubeflow.katib import ApiClient +from kubeflow.katib import KatibClient +from kubeflow.katib import models from kubeflow.katib.constants import constants +from kubeflow.katib.utils.utils import FakeResponse +from kubernetes import client +import yaml # Experiment timeout is 40 min. EXPERIMENT_TIMEOUT = 60 * 40 diff --git a/test/unit/v1beta1/earlystopping/test_medianstop_service.py b/test/unit/v1beta1/earlystopping/test_medianstop_service.py index 8c693d8c3b6..2c1da34844f 100644 --- a/test/unit/v1beta1/earlystopping/test_medianstop_service.py +++ b/test/unit/v1beta1/earlystopping/test_medianstop_service.py @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import grpc -import grpc_testing import unittest from unittest.mock import patch -from pkg.apis.manager.v1beta1.python import api_pb2 +import grpc +import grpc_testing +import utils +from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.earlystopping.v1beta1.medianstop.service import MedianStopService -import utils - class TestMedianStop(unittest.TestCase): def setUp(self): diff --git a/test/unit/v1beta1/metricscollector/test_tfevent_metricscollector.py b/test/unit/v1beta1/metricscollector/test_tfevent_metricscollector.py index ca5c01b5d24..305954e9081 100644 --- a/test/unit/v1beta1/metricscollector/test_tfevent_metricscollector.py +++ b/test/unit/v1beta1/metricscollector/test_tfevent_metricscollector.py @@ -14,6 +14,7 @@ import os import unittest + import utils diff --git a/test/unit/v1beta1/metricscollector/utils.py b/test/unit/v1beta1/metricscollector/utils.py index 9e7f02903d0..d1913be22c4 100644 --- a/test/unit/v1beta1/metricscollector/utils.py +++ b/test/unit/v1beta1/metricscollector/utils.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tfevent_loader import MetricsCollector from google.protobuf import json_format +from tfevent_loader import MetricsCollector def get_metric_logs(logs_dir, metric_names): diff --git a/test/unit/v1beta1/suggestion/test_darts_service.py b/test/unit/v1beta1/suggestion/test_darts_service.py index 0f4defd7d5f..c3cc792ba76 100644 --- a/test/unit/v1beta1/suggestion/test_darts_service.py +++ b/test/unit/v1beta1/suggestion/test_darts_service.py @@ -12,14 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import json +import unittest + import grpc import grpc_testing -import unittest -import json from pkg.apis.manager.v1beta1.python import api_pb2 - -from pkg.suggestion.v1beta1.nas.darts.service import DartsService, validate_algorithm_settings +from pkg.suggestion.v1beta1.nas.darts.service import DartsService +from pkg.suggestion.v1beta1.nas.darts.service import \ + validate_algorithm_settings class TestDarts(unittest.TestCase): diff --git a/test/unit/v1beta1/suggestion/test_enas_service.py b/test/unit/v1beta1/suggestion/test_enas_service.py index 3da9a4d09fc..aaf044b55f3 100644 --- a/test/unit/v1beta1/suggestion/test_enas_service.py +++ b/test/unit/v1beta1/suggestion/test_enas_service.py @@ -14,15 +14,13 @@ import os import shutil +import unittest import grpc import grpc_testing -import unittest - import pytest from pkg.apis.manager.v1beta1.python import api_pb2 - from pkg.suggestion.v1beta1.nas.enas.service import EnasService diff --git a/test/unit/v1beta1/suggestion/test_hyperband_service.py b/test/unit/v1beta1/suggestion/test_hyperband_service.py index 4d7cd47494f..0709f10c56b 100644 --- a/test/unit/v1beta1/suggestion/test_hyperband_service.py +++ b/test/unit/v1beta1/suggestion/test_hyperband_service.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import unittest + import grpc import grpc_testing -import unittest from pkg.apis.manager.v1beta1.python import api_pb2 - from pkg.suggestion.v1beta1.hyperband.service import HyperbandService diff --git a/test/unit/v1beta1/suggestion/test_hyperopt_service.py b/test/unit/v1beta1/suggestion/test_hyperopt_service.py index 317386a909d..30486efa5d4 100644 --- a/test/unit/v1beta1/suggestion/test_hyperopt_service.py +++ b/test/unit/v1beta1/suggestion/test_hyperopt_service.py @@ -16,12 +16,11 @@ import grpc import grpc_testing +import utils from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.suggestion.v1beta1.hyperopt.service import HyperoptService -import utils - class TestHyperopt(unittest.TestCase): def setUp(self): diff --git a/test/unit/v1beta1/suggestion/test_optuna_service.py b/test/unit/v1beta1/suggestion/test_optuna_service.py index ba86188786a..966e5bec535 100644 --- a/test/unit/v1beta1/suggestion/test_optuna_service.py +++ b/test/unit/v1beta1/suggestion/test_optuna_service.py @@ -15,12 +15,11 @@ import grpc import grpc_testing import pytest +import utils from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.suggestion.v1beta1.optuna.service import OptunaService -import utils - class TestOptuna: def setup_method(self): diff --git a/test/unit/v1beta1/suggestion/test_skopt_service.py b/test/unit/v1beta1/suggestion/test_skopt_service.py index 2e8b3eb409c..86dc6f45515 100644 --- a/test/unit/v1beta1/suggestion/test_skopt_service.py +++ b/test/unit/v1beta1/suggestion/test_skopt_service.py @@ -16,12 +16,11 @@ import grpc import grpc_testing +import utils from pkg.apis.manager.v1beta1.python import api_pb2 from pkg.suggestion.v1beta1.skopt.service import SkoptService -import utils - class TestSkopt(unittest.TestCase): def setUp(self):