lightning/.github/workflows/ci_test-full.yml

169 lines
6.3 KiB
YAML
Raw Normal View History

name: Test
# 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, "release/*"]
pull_request:
branches: [master, "release/*"]
2021-04-19 13:49:25 +00:00
types: [opened, reopened, ready_for_review, synchronize]
jobs:
2021-04-19 13:49:25 +00:00
cpu:
runs-on: ${{ matrix.os }}
2021-04-19 13:49:25 +00:00
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-2019, macOS-10.15]
2021-11-04 17:26:24 +00:00
python-version: ["3.7", "3.9"] # minimum, maximum
requires: ["oldest", "latest"]
release: ["stable"]
exclude:
# Skip if torch<1.8 and py3.9 on Linux: https://github.com/pytorch/pytorch/issues/50014
- {os: ubuntu-18.04, python-version: "3.9", requires: "oldest", release: "stable"}
2021-12-21 17:06:15 +00:00
#include:
2021-11-04 17:26:24 +00:00
# nightly: add when there's a release candidate
#- {os: ubuntu-20.04, python-version: "3.10", requires: "latest", release: "pre"}
timeout-minutes: 40
steps:
2020-03-06 01:44:28 +00:00
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Weekly reset caching
run: echo "::set-output name=period::$(python -c 'import time ; days = time.time() / 60 / 60 / 24 ; print(int(days / 7))' 2>&1)"
id: times
2021-10-26 11:58:20 +00:00
- name: Upgrade pip
run: |
2021-10-26 11:58:20 +00:00
python --version
# needed for `pip cache` command
2021-10-26 11:58:20 +00:00
pip install --upgrade pip --user
pip --version
# Github Actions: Run step on specific OS: https://stackoverflow.com/a/57948488/4521646
- name: Setup macOS
if: runner.os == 'macOS'
run: |
brew install openmpi libuv # Horovod on macOS requires OpenMPI, Gloo not currently supported
- name: Setup Windows
if: runner.os == 'windows'
run: |
python .github/prune-packages.py requirements/extra.txt "horovod"
- name: Set min. dependencies
2021-11-04 17:26:24 +00:00
if: matrix.requires == 'oldest'
run: |
python .github/set-min-requirements.py
# 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 dir
id: pip-cache
run: |
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-td${{ steps.times.outputs.period }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements/extra.txt') }}
restore-keys: |
${{ runner.os }}-pip-td${{ steps.times.outputs.period }}-py${{ matrix.python-version }}-${{ matrix.release }}-${{ matrix.requires }}-
- name: Pull checkpoints from S3
working-directory: ./legacy
run: |
# wget is simpler but does not work on Windows
python -c "from urllib.request import urlretrieve ; urlretrieve('https://pl-public-data.s3.amazonaws.com/legacy/checkpoints.zip', 'checkpoints.zip')"
ls -l .
unzip -o checkpoints.zip
ls -l checkpoints/
2021-10-26 11:58:20 +00:00
- name: Install dependencies
run: |
2021-10-26 11:58:20 +00:00
flag=$(python -c "print('--pre' if '${{matrix.release}}' == 'pre' else '')" 2>&1)
pip install --requirement requirements.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade $flag
# adjust versions according installed Torch version
python ./requirements/adjust_versions.py requirements/examples.txt
pip install --requirement requirements/examples.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade
pip install --requirement requirements/test.txt --upgrade
pip list
shell: bash
2021-10-26 11:58:20 +00:00
- name: Install extra dependencies
env:
HOROVOD_BUILD_ARCH_FLAGS: "-mfma"
HOROVOD_WITHOUT_MXNET: 1
HOROVOD_WITHOUT_TENSORFLOW: 1
run: |
# adjust versions according installed Torch version
python ./requirements/adjust_versions.py requirements/extra.txt
2021-10-26 11:58:20 +00:00
pip install --requirement ./requirements/extra.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade
pip list
shell: bash
- name: Reinstall Horovod if necessary
2021-10-26 11:58:20 +00:00
if: runner.os != 'windows'
env:
HOROVOD_BUILD_ARCH_FLAGS: "-mfma"
2021-10-26 11:58:20 +00:00
HOROVOD_WITHOUT_MXNET: 1
HOROVOD_WITHOUT_TENSORFLOW: 1
run: |
2020-07-30 21:39:07 +00:00
HOROVOD_BUILT=$(python -c "import horovod.torch; horovod.torch.nccl_built(); print('SUCCESS')" || true)
if [[ $HOROVOD_BUILT != "SUCCESS" ]]; then
pip uninstall -y horovod
2020-10-06 15:18:16 +00:00
echo $(grep "horovod" requirements/extra.txt) > requirements/horovod.txt
pip install --no-cache-dir -r requirements/horovod.txt
fi
horovodrun --check-build
shell: bash
- name: Cache datasets
uses: actions/cache@v2
with:
path: Datasets
key: pl-dataset
- name: Tests
run: |
# NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003
coverage run --source pytorch_lightning -m pytest pytorch_lightning tests -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml
- name: Examples
run: |
python -m pytest pl_examples -v --durations=10
2021-03-11 15:45:26 +00:00
- name: Upload pytest results
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}
path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}-${{ matrix.release }}.xml
if: failure()
- name: Statistics
if: success()
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: always()
2020-10-19 07:28:17 +00:00
# see: https://github.com/actions/toolkit/issues/399
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
2021-03-11 15:45:26 +00:00
flags: cpu,pytest,python${{ matrix.python-version }}
name: CPU-coverage
fail_ci_if_error: false