diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml new file mode 100644 index 0000000000000000000000000000000000000000..e3da50ce74b6c60bd40bd81ae146ec810400167e --- /dev/null +++ b/.github/workflows/ci-testing.yml @@ -0,0 +1,70 @@ +name: CI testing + +# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows +on: + # Trigger the workflow on push or pull request, but only for the master branch + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + pytest: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, macOS-10.15, windows-2019] + python-version: [3.7] + + # Timeout: https://stackoverflow.com/a/59076067/4521646 + timeout-minutes: 35 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + # Github Actions: Run step on specific OS: https://stackoverflow.com/a/57948488/4521646 + - name: Setup macOS + if: runner.os == 'macOS' + run: | + brew install libomp # https://github.com/pytorch/pytorch/issues/20030 + + # Note: This uses an internal pip API and may not always work + # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow + - name: Get pip cache + id: pip-cache + run: | + python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)" + + - name: Cache pip + uses: actions/cache@v2 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-py${{ matrix.python-version }}- + + - name: Install dependencies + run: | + pip install --requirement requirements.txt --upgrade --quiet --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --use-feature=2020-resolver + pip install --requirement tests/requirements.txt --quiet --use-feature=2020-resolver + python --version + pip --version + pip list + shell: bash + + - name: Tests + run: | + coverage run --source project -m py.test project tests -v --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml + + - name: Statistics + if: success() + run: | + coverage report diff --git a/README.md b/README.md index 82d6463aca5a115dacd2701cea0b1c9664554bd9..63571ba176703b654531f40001dc5e98889ce98e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ The goal of this seed is to structure ML paper-code the same so that work can ea ARXIV [](https://www.nature.com/articles/nature14539) --> + <!-- diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..268bbb91147fa47cadd73ae3ad6f777195cee15a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,43 @@ +[tool:pytest] +norecursedirs = + .git + dist + build +addopts = + --strict + --doctest-modules + --durations=0 + +[coverage:report] +exclude_lines = + pragma: no-cover + pass + +[flake8] +max-line-length = 120 +exclude = .tox,*.egg,build,temp +select = E,W,F +doctests = True +verbose = 2 +# https://pep8.readthedocs.io/en/latest/intro.html#error-codes +format = pylint +# see: https://www.flake8rules.com/ +ignore = + E731 # Do not assign a lambda expression, use a def + W504 # Line break occurred after a binary operator + F401 # Module imported but unused + F841 # Local variable name is assigned to but never used + W605 # Invalid escape sequence 'x' + +# setup.cfg or tox.ini +[check-manifest] +ignore = + *.yml + .github + .github/* + +[metadata] +license_file = LICENSE +description-file = README.md +# long_description = file:README.md +# long_description_content_type = text/markdown diff --git a/setup.py b/setup.py index ff891d70bb3ca1b3c94415a7df2c95af3346e0b9..3de44ddb7dcf7a866421b6aade7ebad55e8752f3 100644 --- a/setup.py +++ b/setup.py @@ -13,3 +13,4 @@ setup( install_requires=['pytorch-lightning'], packages=find_packages(), ) + diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..09f038f59883c58581571d1d1d52e3b745a369ca --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,8 @@ +coverage +codecov>=2.1 +pytest>=3.0.5 +pytest-cov +pytest-flake8 +flake8 +check-manifest +twine==1.13.0 \ No newline at end of file diff --git a/tests/test_classifier.py b/tests/test_classifier.py index a11a314e075ffe6e61e21a46f198e355f1e71f40..96be92bdd6c6ba8a7b00f7ab07b1a04772638b04 100644 --- a/tests/test_classifier.py +++ b/tests/test_classifier.py @@ -1,7 +1,7 @@ -from project.datasets.mnist import mnist -from project.lit_classifier_main import LitClassifier from pytorch_lightning import Trainer, seed_everything +from project.lit_classifier_main import LitClassifier + def test_lit_classifier(): seed_everything(1234)