Merge pull request #63 from Leengit/use_torch_device #170
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, test, package | |
on: [push,pull_request] | |
jobs: | |
test-python: | |
runs-on: ubuntu-20.04 | |
strategy: | |
max-parallel: 2 | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
include: | |
- batchbald_redux-git-tag: "" | |
- flake8-python-git-tag: "" | |
- pytest-python-git-tag: "" | |
- tensorflow-python-git-tag: "<3.0.0" | |
- torch-python-git-tag: "<2.0.0" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 'Free up disk space' | |
run: | | |
# Workaround for https://github.com/actions/virtual-environments/issues/709 | |
df -h | |
sudo apt-get clean | |
sudo rm -rf "/usr/local/share/boost" | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
df -h | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install 'flake8${{ matrix.flake8-python-git-tag }}' | |
pip install 'pytest${{ matrix.pytest-python-git-tag }}' | |
- name: Install machine learning frameworks and al_bench | |
run: | | |
pip install 'tensorflow${{ matrix.tensorflow-python-git-tag }}' | |
pip install 'torch${{ matrix.torch-python-git-tag }}' | |
pip install 'batchbald_redux${{ matrix.batchbald_redux-python-git-tag }}' | |
pip install . | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars | |
# wide. Python 'black' defaults to a line length of 88 characters. | |
flake8 . --count --exit-zero --ignore=E203,W503 --max-complexity=10 --max-line-length=88 --statistics | |
- name: Test with pytest | |
run: | | |
cd test | |
pytest | |
shell: bash | |
build-n-publish: | |
name: Build and publish Python 🐍 distributions 📦 to PyPI | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@master | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v1 | |
with: | |
python-version: "3.9" | |
- name: Install pypa/build | |
run: >- | |
python -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
run: >- | |
python -m build --sdist --wheel --outdir dist/ . | |
- name: Publish distribution 📦 to PyPI | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |