Skip to content

Commit

Permalink
Begin enabling pre-commit hooks
Browse files Browse the repository at this point in the history
Signed-off-by: droctothorpe <[email protected]>
  • Loading branch information
droctothorpe committed May 7, 2024
1 parent 1551ca3 commit 745fca8
Show file tree
Hide file tree
Showing 107 changed files with 447 additions and 281 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit/action.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
61 changes: 61 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions cmd/earlystopping/medianstop/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions cmd/metricscollector/v1beta1/tfevent-metricscollector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions cmd/suggestion/hyperband/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions cmd/suggestion/hyperopt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions cmd/suggestion/nas/darts/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions cmd/suggestion/nas/enas/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 5 additions & 3 deletions cmd/suggestion/optuna/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions cmd/suggestion/pbt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions cmd/suggestion/skopt/v1beta1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion docs/release/changelog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from github import Github
import argparse

from github import Github

REPO_NAME = "kubeflow/katib"
CHANGELOG_FILE = "CHANGELOG.md"

Expand Down
11 changes: 5 additions & 6 deletions examples/v1beta1/kubeflow-pipelines/mpi-job-horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion examples/v1beta1/trial-images/darts-cnn-cifar10/architect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion examples/v1beta1/trial-images/darts-cnn-cifar10/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
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.

import torch.nn as nn
import torch
import torch.nn as nn

OPS = {
'none': lambda channels, stride: Zero(stride),
Expand Down
11 changes: 5 additions & 6 deletions examples/v1beta1/trial-images/darts-cnn-cifar10/run_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from collections import namedtuple

import torch


Expand Down
26 changes: 20 additions & 6 deletions examples/v1beta1/trial-images/enas-cnn-cifar10/ModelConstructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 7 additions & 4 deletions examples/v1beta1/trial-images/enas-cnn-cifar10/RunTrial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading

0 comments on commit 745fca8

Please sign in to comment.