mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
e1c9503951
also want to show how much faster it will run now with cached pkgs
130 lines
4.2 KiB
YAML
130 lines
4.2 KiB
YAML
name: Test Invoke with Conda
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'development'
|
|
pull_request:
|
|
branches:
|
|
- 'main'
|
|
- 'development'
|
|
|
|
jobs:
|
|
os_matrix:
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest]
|
|
include:
|
|
- os: ubuntu-latest
|
|
environment-file: environment.yml
|
|
default-shell: bash -l {0}
|
|
- os: macos-latest
|
|
environment-file: environment-mac.yml
|
|
default-shell: bash -l {0}
|
|
name: Test invoke.py on ${{ matrix.os }} with conda
|
|
runs-on: ${{ matrix.os }}
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.default-shell }}
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
- name: setup miniconda
|
|
uses: conda-incubator/setup-miniconda@v2
|
|
with:
|
|
auto-activate-base: false
|
|
auto-update-conda: false
|
|
miniconda-version: latest
|
|
|
|
- name: set test prompt to main branch validation
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
run: echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV
|
|
|
|
- name: set test prompt to development branch validation
|
|
if: ${{ github.ref == 'refs/heads/development' }}
|
|
run: echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV
|
|
|
|
- name: set test prompt to Pull Request validation
|
|
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }}
|
|
run: echo "TEST_PROMPTS=tests/pr_prompt.txt" >> $GITHUB_ENV
|
|
|
|
- name: set conda environment name
|
|
run: echo "CONDA_ENV_NAME=invokeai" >> $GITHUB_ENV
|
|
|
|
- name: Use Cached Stable Diffusion v1.4 Model
|
|
id: cache-sd-v1-4
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-sd-v1-4
|
|
with:
|
|
path: models/ldm/stable-diffusion-v1/model.ckpt
|
|
key: ${{ env.cache-name }}
|
|
restore-keys: ${{ env.cache-name }}
|
|
|
|
- name: Download Stable Diffusion v1.4 Model
|
|
if: ${{ steps.cache-sd-v1-4.outputs.cache-hit != 'true' }}
|
|
run: |
|
|
[[ -d models/ldm/stable-diffusion-v1 ]] \
|
|
|| mkdir -p models/ldm/stable-diffusion-v1
|
|
[[ -r models/ldm/stable-diffusion-v1/model.ckpt ]] \
|
|
|| curl -o models/ldm/stable-diffusion-v1/model.ckpt ${{ secrets.SD_V1_4_URL }}
|
|
|
|
- name: Use cached Conda Environment
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-conda-env-${{ env.CONDA_ENV_NAME }}
|
|
conda-env-file: ${{ matrix.environment-file }}
|
|
with:
|
|
path: ${{ env.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}
|
|
key: ${{ env.cache-name }}
|
|
restore-keys: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }}
|
|
|
|
- name: Use cached Conda Packages
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-conda-env-${{ env.CONDA_ENV_NAME }}
|
|
conda-env-file: ${{ matrix.environment-file }}
|
|
with:
|
|
path: ${{ env.CONDA_PKGS_DIR }}
|
|
key: ${{ env.cache-name }}
|
|
restore-keys: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(env.conda-env-file) }}
|
|
|
|
- name: Activate Conda Env
|
|
uses: conda-incubator/setup-miniconda@v2
|
|
with:
|
|
activate-environment: ${{ env.CONDA_ENV_NAME }}
|
|
environment-file: ${{ matrix.environment-file }}
|
|
|
|
- name: list conda packages
|
|
run: |
|
|
conda list \
|
|
-n invokeai | \
|
|
awk ' {print " - " $1 "==" $2;} '
|
|
|
|
- name: Use Cached Huggingface and Torch models
|
|
id: cache-hugginface-torch
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: cache-hugginface-torch
|
|
with:
|
|
path: ~/.cache
|
|
key: ${{ env.cache-name }}
|
|
restore-keys: |
|
|
${{ env.cache-name }}-${{ hashFiles('scripts/preload_models.py') }}
|
|
|
|
- name: run preload_models.py
|
|
run: python scripts/preload_models.py
|
|
|
|
- name: Run the tests
|
|
run: |
|
|
time python scripts/invoke.py \
|
|
--from_file ${{ env.TEST_PROMPTS }}
|
|
mkdir -p outputs/img-samples
|
|
|
|
- name: Archive results
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: results_${{ matrix.os }}
|
|
path: outputs/img-samples
|