From 404f686330a6d5c267565807956ac6116b44aa26 Mon Sep 17 00:00:00 2001 From: Luke Wood Date: Tue, 9 Nov 2021 12:11:25 -0800 Subject: [PATCH] Create operational resources This commit begins implementing the operational pieces of the keras-cv repo. This includes a setup.py package, a github action to lint, and scripts to complete linting. --- .github/workflows/actions.yml | 35 ++++++++++++++++++++ .gitignore | 27 ++++++++++++++++ setup.py | 61 +++++++++++++++++++++++++++++++++++ shell/format.sh | 4 +++ shell/lint.sh | 27 ++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 .github/workflows/actions.yml create mode 100644 .gitignore create mode 100644 setup.py create mode 100755 shell/format.sh create mode 100755 shell/lint.sh diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000000..a90df4250f --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,35 @@ +name: Tests + +on: + push: + pull_request: + release: + types: [created] +jobs: + format: + name: Check the code format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Get pip cache dir + id: pip-cache + run: | + python -m pip install --upgrade pip setuptools + echo "::set-output name=dir::$(pip cache dir)" + - name: pip cache + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: | + pip install tensorflow + pip install -e ".[tests]" --progress-bar off --upgrade + - name: Lint + run: bash shell/lint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..7d9809fb9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +keras_cv.egg-info/ +*.swp +.idea +*.pyc +.pytest_cache +*.egg-info + +#VS Code files and container +.vscode/ +.devcontainer/ + +build/ +dist/ +bigquery/ +export/ +logs/ +Keras_Tuner.egg-info/ +results/ +tmp/ +.ipynb_checkpoints/ +*_tutorial_results/ +tmp.py +.coverage +.coverage.* +htmlcov +old_code/ +docs/sources diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000..d62b48e128 --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +# Copyright 2019 The KerasCV Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Setup script.""" + +from setuptools import find_packages +from setuptools import setup + +setup( + name="keras-cv", + description="Computer Vision extensions for Keras.", + url="https://github.com/keras-team/keras-cv", + author="The KerasCV authors", + author_email="keras-cv@google.com", + license="Apache License 2.0", + # tensorflow isn't a dependency because it would force the + # download of the gpu version or the cpu version. + # users should install it manually. + install_requires=[ + "packaging", + "numpy", + "requests", + "scipy", + "tensorboard", + "ipython", + "kt-legacy", + ], + extras_require={ + "tests": [ + "pytest", + "flake8", + "isort", + "black", + "portpicker", + "pytest-xdist", + "pytest-cov", + ], + }, + classifiers=[ + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Operating System :: Unix", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", + ], + packages=find_packages(exclude=("tests",)), +) diff --git a/shell/format.sh b/shell/format.sh new file mode 100755 index 0000000000..9615ac4f1e --- /dev/null +++ b/shell/format.sh @@ -0,0 +1,4 @@ +#!/bin/bash +isort --sl . +black --line-length 85 . + diff --git a/shell/lint.sh b/shell/lint.sh new file mode 100755 index 0000000000..07509390b8 --- /dev/null +++ b/shell/lint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +isort --sl -c . +if ! [ $? -eq 0 ] +then + echo "Please run \"sh shell/format.sh\" to format the code." + exit 1 +fi +flake8 . +if ! [ $? -eq 0 ] +then + echo "Please fix the code style issue." + exit 1 +fi +black --check --line-length 85 . +if ! [ $? -eq 0 ] +then + echo "Please run \"sh shell/format.sh\" to format the code." + exit 1 +fi +for i in $(find keras_cv tests -name '*.py') # or whatever other pattern... +do + if ! grep -q Copyright $i + then + echo "Please run \"sh shell/format.sh\" to format the code." + exit 1 + fi +done