Skip to content

Commit

Permalink
update e2e test for tune api
Browse files Browse the repository at this point in the history
Signed-off-by: helenxie-bit <[email protected]>
  • Loading branch information
helenxie-bit committed Sep 3, 2024
2 parents 752c712 + e251a07 commit 0e41aab
Show file tree
Hide file tree
Showing 73 changed files with 2,221 additions and 1,996 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-tune-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Install Training Operator SDK
shell: bash
run: pip install kubeflow[huggingface]
run: pip install kubeflow-training[huggingface]

- name: Run e2e test with tune API
uses: ./.github/workflows/template-e2e-test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-setup-e2e-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runs:
version: ${{ inputs.kubernetes-version }}

- name: Setup Minikube Cluster
uses: medyagh/[email protected].16
uses: medyagh/[email protected].18
with:
network-plugin: cni
cni: flannel
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ repos:
hooks:
- id: isort
name: isort
entry: isort --profile google
entry: isort --profile black
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
files: (sdk|examples)/.*
files: (sdk|examples|pkg)/.*
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
files: (sdk|examples)/.*
files: (sdk|examples|pkg)/.*
exclude: |
(?x)^(
.*zz_generated.deepcopy.*|
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ ifeq ("$(wildcard $(TEST_TENSORFLOW_EVENT_FILE_PATH))", "")
python examples/v1beta1/trial-images/tf-mnist-with-summaries/mnist.py --epochs 5 --batch-size 200 --log-path $(TEST_TENSORFLOW_EVENT_FILE_PATH)
endif

# TODO(Electronic-Waste): Remove the import rewrite when protobuf supports `python_package` option.
# REF: https://github.com/protocolbuffers/protobuf/issues/7061
pytest: prepare-pytest prepare-pytest-testdata
pytest ./test/unit/v1beta1/suggestion --ignore=./test/unit/v1beta1/suggestion/test_skopt_service.py
pytest ./test/unit/v1beta1/earlystopping
pytest ./test/unit/v1beta1/metricscollector
cp ./pkg/apis/manager/v1beta1/python/api_pb2.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2.py
cp ./pkg/apis/manager/v1beta1/python/api_pb2_grpc.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py
sed -i "s/api_pb2/kubeflow\.katib\.katib_api_pb2/g" ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py
pytest ./sdk/python/v1beta1/kubeflow/katib
rm ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2.py
rm ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py

# The skopt service doesn't work appropriately with Python 3.11.
# So, we need to run the test with Python 3.9.
Expand Down
2 changes: 1 addition & 1 deletion cmd/earlystopping/medianstop/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import logging
import time
from concurrent import futures

import grpc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.

import argparse
from logging import getLogger
from logging import INFO
from logging import StreamHandler
from logging import INFO, StreamHandler, getLogger

import api_pb2
import api_pb2_grpc
Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/hyperband/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/hyperopt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/nas/darts/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/nas/enas/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/optuna/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/pbt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
2 changes: 1 addition & 1 deletion cmd/suggestion/skopt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from concurrent import futures
import time
from concurrent import futures

import grpc

Expand Down
22 changes: 12 additions & 10 deletions examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,19 @@
# https://www.kubeflow.org/docs/components/training/mpi/

import kfp
from kfp import components
import kfp.dsl as dsl
from kubeflow.katib import ApiClient
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 V1beta1TrialParameterSpec
from kubeflow.katib import V1beta1TrialTemplate
from kfp import components
from kubeflow.katib import (
ApiClient,
V1beta1AlgorithmSetting,
V1beta1AlgorithmSpec,
V1beta1ExperimentSpec,
V1beta1FeasibleSpace,
V1beta1ObjectiveSpec,
V1beta1ParameterSpec,
V1beta1TrialParameterSpec,
V1beta1TrialTemplate,
)


@dsl.pipeline(
Expand Down
4 changes: 1 addition & 3 deletions examples/v1beta1/trial-images/darts-cnn-cifar10/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
# 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, MixedOp, StdConv


class Cell(nn.Module):
Expand Down
6 changes: 3 additions & 3 deletions examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import argparse
import json

from architect import Architect
from model import NetworkCNN
import numpy as np
from search_space import SearchSpace
import torch
import torch.nn as nn
import utils
from architect import Architect
from model import NetworkCNN
from search_space import SearchSpace


def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@

import json

from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import GlobalAveragePooling2D
from keras.layers import Input
from keras.layers import Dense, Dropout, GlobalAveragePooling2D, Input
from keras.models import Model
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
from op_library import concat, conv, dw_conv, reduction, sp_conv


class ModelConstructor(object):
Expand Down
6 changes: 2 additions & 4 deletions examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

import argparse

import tensorflow as tf
from keras.datasets import cifar10
from ModelConstructor import ModelConstructor
from tensorflow import keras
import tensorflow as tf
from tensorflow.keras.layers import RandomFlip
from tensorflow.keras.layers import RandomTranslation
from tensorflow.keras.layers import Rescaling
from tensorflow.keras.layers import RandomFlip, RandomTranslation, Rescaling
from tensorflow.keras.utils import to_categorical

if __name__ == "__main__":
Expand Down
22 changes: 12 additions & 10 deletions examples/v1beta1/trial-images/enas-cnn-cifar10/op_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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 DepthwiseConv2D
from keras.layers import MaxPooling2D
from keras.layers import SeparableConv2D
from keras.layers import ZeroPadding2D
import numpy as np
from keras import backend as K
from keras.layers import (
Activation,
AveragePooling2D,
BatchNormalization,
Conv2D,
DepthwiseConv2D,
MaxPooling2D,
SeparableConv2D,
ZeroPadding2D,
concatenate,
)


def concat(inputs):
Expand Down
3 changes: 1 addition & 2 deletions examples/v1beta1/trial-images/pytorch-mnist/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets
from torchvision import transforms
from torchvision import datasets, transforms

WORLD_SIZE = int(os.environ.get("WORLD_SIZE", 1))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

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
from tensorflow.keras.layers import Conv2D, Dense, Flatten


class MyModel(Model):
Expand Down
8 changes: 6 additions & 2 deletions hack/gen-python-sdk/post_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def _rewrite_helper(input_file, output_file, rewrite_rules):
if output_file == "sdk/python/v1beta1/kubeflow/katib/__init__.py":
lines.append("# Import Katib API client.\n")
lines.append("from kubeflow.katib.api.katib_client import KatibClient\n")
lines.append("# Import Katib report metrics functions")
lines.append("from kubeflow.katib.api.report_metrics import report_metrics")
lines.append("# Import Katib TrainerResources class.\n")
lines.append(
"from kubeflow.katib.types.trainer_resources import TrainerResources\n"
)
lines.append("# Import Katib report metrics functions\n")
lines.append("from kubeflow.katib.api.report_metrics import report_metrics\n")
lines.append("# Import Katib helper functions.\n")
lines.append("import kubeflow.katib.api.search as search\n")
lines.append("# Import Katib helper constants.\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const (
DistributionLogUniform Distribution = "logUniform"
DistributionNormal Distribution = "normal"
DistributionLogNormal Distribution = "logNormal"
DistributionUnknown Distribution = "unknown"
)

// TrialTemplate describes structure of trial template
Expand Down
Loading

0 comments on commit 0e41aab

Please sign in to comment.