|
|
|
name: Python Checks
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
|
|
PIP_DISABLE_PIP_VERSION_CHECK: 1
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-python@v4.5.0
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
- name: Cache dependencies
|
|
|
|
uses: actions/cache@v3.2.4
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: ${{ env.pythonLocation }}
|
|
|
|
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements-dev.txt') }}-lint
|
|
|
|
- name: Install Ruff
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: grep -E 'ruff==' requirements-dev.txt | xargs pip install
|
|
|
|
- name: Lint
|
|
|
|
run: |
|
|
|
|
echo "::add-matcher::.github/pylama_matcher.json"
|
|
|
|
ruff --config tests/ruff.toml .
|
|
|
|
autoformat:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-python@v4.5.0
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
- name: Cache dependencies
|
|
|
|
uses: actions/cache@v3.2.4
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: ${{ env.pythonLocation }}
|
|
|
|
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements-dev.txt') }}-autoformat
|
|
|
|
- name: Install Black
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: grep -E 'black==' requirements-dev.txt | xargs pip install
|
|
|
|
- name: Lint
|
|
|
|
run: |
|
|
|
|
black --diff --fast .
|
|
|
|
test-gpu:
|
|
|
|
runs-on: nvidia-4090
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
# cache: pip
|
|
|
|
# cache-dependency-path: requirements-dev.txt
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip uninstall torch torchvision xformers triton imaginairy -y
|
|
|
|
python -m pip install -r requirements-dev.in . --upgrade
|
|
|
|
- name: Test with pytest
|
|
|
|
timeout-minutes: 30
|
|
|
|
env:
|
|
|
|
CUDA_LAUNCH_BLOCKING: 1
|
|
|
|
run: |
|
|
|
|
pytest --durations=10 -v -m "gputest"
|
|
|
|
test-non-gpu:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
python-version: ["3.10"]
|
|
|
|
os: ["ubuntu-latest"]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
cache: pip
|
|
|
|
cache-dependency-path: requirements-dev.txt
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install -r requirements-dev.in . --upgrade
|
|
|
|
- name: Test with pytest
|
|
|
|
timeout-minutes: 30
|
|
|
|
env:
|
|
|
|
CUDA_LAUNCH_BLOCKING: 1
|
|
|
|
run: |
|
|
|
|
pytest --durations=10 -v -m "not gputest"
|
|
|
|
type-check:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-python@v4.5.0
|
|
|
|
with:
|
|
|
|
python-version: "3.10"
|
|
|
|
cache: pip
|
|
|
|
cache-dependency-path: requirements-dev.txt
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install -r requirements-dev.txt . --upgrade
|
|
|
|
- name: Run mypy
|
|
|
|
run: |
|
|
|
|
make type-check
|