feat: use python mmap module #24
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: Lint and Test | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10"] | |
torch-version: ["^1.13.0", "2.0.0"] | |
# v2.0.1 is currently buggy: https://github.com/pytorch/pytorch/issues/100974 | |
# torch-version: ["^1.13.0", "^2.0.1"] | |
steps: | |
# check-out repo and setup python | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
# setup Python | |
- name: Set up python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# install & configure poetry | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
# load cached venv if cache exists | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v2 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ matrix.torch-version }}-${{ hashFiles('**/poetry.lock') }} | |
# install dependencies if cache does not exist | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
# install torch | |
- name: Install torch | |
run: poetry add torch=${{ matrix.torch-version }} --no-interaction | |
# install the root project, if required | |
- name: Install library | |
run: poetry install --no-interaction | |
# run pre-commit hooks | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Run pre-commit hooks | |
run: poetry run pre-commit run --all-files --show-diff-on-failure --color=always | |
# run test suite with coverage | |
- name: Run tests | |
run: | | |
poetry run pytest --cov=torchcache/ --cov-report=xml --cov-report=term-missing --cov-fail-under=50 --cov-branch --color=yes | |
# upload coverage report to codecov | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./coverage.xml | |
fail_ci_if_error: true | |
publish: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags') | |
steps: | |
# check-out repo and setup python | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
# setup Python | |
- name: Set up python 3.8 | |
id: setup-python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.8" | |
# install & configure poetry | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Publish package | |
env: | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
poetry config pypi-token.pypi $PYPI_TOKEN | |
poetry publish --build |