Skip to content

ci: use uv

ci: use uv #887

Workflow file for this run

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: Format
run: |
echo "::add-matcher::.github/pylama_matcher.json"
ruff format --config tests/ruff.toml . --check
- name: Lint
run: |
echo "::add-matcher::.github/pylama_matcher.json"
ruff --config tests/ruff.toml .
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 install uv
uv pip uninstall torch torchvision xformers triton imaginairy -y
uv pip sync requirements-dev.txt
uv pip install -e .
- 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"
- "3.11"
# torch for python 3.12 is not available yet
# https://github.com/pytorch/pytorch/issues/110436
# - "3.12"
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install uv
uv pip sync requirements-dev.txt
uv pip install -e .
- 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
build-wheel:
name: Build Wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.5.0
with:
python-version: "3.10"
- name: Install dependencies
run: python -m pip install wheel
- name: Build package
run: python setup.py bdist_wheel
- name: Rename wheel
run: mv dist/*.whl dist/imaginAIry-0.0.1b0-py3-none-any.whl
- uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
smoke-test-wheel:
needs: build-wheel
name: Smoketest (Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Install built wheel
run: |
python -m pip install dist/imaginAIry-0.0.1b0-py3-none-any.whl
- name: Generate an image
run: |
imagine fruit --steps 10 --size 512 --seed 1
- uses: actions/upload-artifact@v3
with:
name: images
path: outputs/generated/*.jpg
smoke-test-wheel-conda:
needs: build-wheel
name: Smoketest (Conda, Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11" ]
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: test-env
create-env-file: true
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Install built wheel
shell: bash -l {0}
run: |
conda activate test-env
python -m pip install dist/imaginAIry-0.0.1b0-py3-none-any.whl
- name: Generate an image
shell: bash -l {0}
run: |
conda activate test-env
imagine fruit --steps 10 --size 512 --seed 1
- uses: actions/upload-artifact@v3
with:
name: images
path: outputs/generated/*.jpg
publish-docs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: python -m pip install -r requirements-dev.in . --upgrade
- run: mkdocs gh-deploy --force