Skip to content

Commit

Permalink
Simplify CI and run training test in parallel (#185)
Browse files Browse the repository at this point in the history
* Cleanup CI

* Split tests into separate jobs

* Remove scipy test dependency

* ⬆️ isort
  • Loading branch information
lgeiger authored Jul 4, 2020
1 parent 1f96968 commit 2b64878
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
python-version: 3.7
- name: Install project dependencies
run: |
pip install tensorflow==2.1.0
pip install tensorflow-cpu==2.2.0
pip install -e .[test]
- name: Run Flake8
run: flake8
- name: Black code style
run: black . --check --target-version py36 --exclude 'build/|buck-out/|dzzist/|_build/|\.git/|\.hg/|\.mypy_cache/|\.tox/|\.venv/|larq/snapshots/'
- name: Check import order with isort
run: isort --check-only --diff
run: isort . --check --diff
- name: Type check with PyType
run: pytype --jobs 2
run: pytype --jobs auto
30 changes: 24 additions & 6 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7]
tf-version: [1.15.2, 2.0.1, 2.1.0, 2.2.0rc3]
tf-version: [1.15.3, 2.0.2, 2.1.1, 2.2.0]
python-version: [3.7]
include:
- tf-version: 2.2.0
python-version: 3.6
- tf-version: 2.2.0
python-version: 3.8
- tf-version: 2.2.0
python-version: 3.7
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -21,13 +28,24 @@ jobs:
python-version: ${{matrix.python-version}}
- name: Install dependencies
run: |
pip install tensorflow==${{matrix.tf-version}}
pip install tensorflow-cpu==${{matrix.tf-version}} || pip install tensorflow==${{matrix.tf-version}}
pip install -e .[test]
- name: Test data and models with pytest
run: pytest . -n auto --ignore=tests/train_test.py --cov=larq_zoo --cov-report=xml --cov-config=.coveragerc
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash) -f ./coverage.xml -F unittests

train-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.7
- name: Install dependencies
run: pip install tensorflow-cpu==2.2.0 -e .[test]
- name: Test training with pytest
if: matrix.python-version == '3.7' && matrix.tf-version == '2.1.0'
run: pytest tests/train_test.py -n auto --cov=larq_zoo --cov-report=xml --cov-config=.coveragerc --cov-append
- name: Upload coverage to Codecov
if: matrix.python-version == '3.7' && matrix.tf-version == '2.1.0'
run: curl -s https://codecov.io/bash | bash -s -- -f ./coverage.xml -F unittests
run: bash <(curl -s https://codecov.io/bash) -f ./coverage.xml -F unittests
3 changes: 1 addition & 2 deletions larq_zoo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import larq_zoo.literature as literature
import larq_zoo.sota as sota
from larq_zoo import literature, sota
from larq_zoo.core.utils import decode_predictions
from larq_zoo.training import datasets
from larq_zoo.training.data import preprocess_input
Expand Down
1 change: 1 addition & 0 deletions larq_zoo/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
try:
from tensorflow.python.keras.applications.imagenet_utils import obtain_input_shape
except ImportError:
# type: ignore
from keras_applications.imagenet_utils import (
_obtain_input_shape as obtain_input_shape,
)
Expand Down
9 changes: 4 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ exclude = build,dist,env,.pytype

[isort]

# Settings for compatibility with black.
profile = black
line_length = 88
use_parentheses = True
multi_line_output = 3
include_trailing_comma = True
# Don't misclassify larq as a first-party import.
known_third_party = larq
skip =
build
dist
env
venv
.venv
.git
.pytype


Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ def readme():
"test": [
"black==19.10b0",
"flake8>=3.7.9,<3.9.0",
"isort~=4.3.21",
"pytype>=2019.10.17,<2020.7.0",
"isort==5.0.1",
"pytype==2020.6.26",
"pytest>=4.3.1",
"pytest-cov>=2.6.1",
"pytest-mock>=3.1.1",
"pytest-xdist==1.32.0",
"Pillow==7.2.0",
"scipy==1.5.0",
"tensorflow_datasets>=3.1.0",
],
},
Expand Down

0 comments on commit 2b64878

Please sign in to comment.