InvokeAI/.github/workflows/test-invoke-conda.yml

134 lines
5.0 KiB
YAML
Raw Normal View History

name: Test Invoke with Conda
on:
push:
branches:
- 'main'
- 'development'
2022-10-28 18:42:14 +00:00
- 'use-bearer-token-to-download-model-debug'
pull_request_target:
2022-10-25 21:27:38 +00:00
branches:
- 'main'
- 'development'
jobs:
matrix:
strategy:
fail-fast: false
matrix:
stable-diffusion-model:
- 'https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt'
- 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt'
os:
- ubuntu-latest
- macOS-12
2022-10-25 21:27:38 +00:00
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}
- stable-diffusion-model: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt
stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/model.ckpt
stable-diffusion-model-switch: stable-diffusion-1.4
- stable-diffusion-model: https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt
stable-diffusion-model-dl-path: models/ldm/stable-diffusion-v1/v1-5-pruned-emaonly.ckpt
stable-diffusion-model-switch: stable-diffusion-1.5
name: Test invoke.py on ${{ matrix.os }} with ${{ matrix.stable-diffusion-model-switch }}
runs-on: ${{ matrix.os }}
env:
CONDA_ENV_NAME: invokeai
2022-10-25 21:27:38 +00:00
defaults:
run:
shell: ${{ matrix.default-shell }}
steps:
- name: Checkout sources
id: checkout-sources
uses: actions/checkout@v3
2022-10-25 21:27:38 +00:00
- name: Use cached conda packages
id: use-cached-conda-packages
uses: actions/cache@v3
with:
path: ~/conda_pkgs_dir
key: conda-pkgs-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles(matrix.environment-file) }}
- name: Use Cached Huggingface and Torch models
id: cache-hugginface-and-torch-models
uses: actions/cache@v3
env:
cache-name: cache-hugginface-and-torch-models
with:
path: ~/.cache
key: ${{ env.cache-name }}
restore-keys: ${{ env.cache-name }}-${{ hashFiles('scripts/preload_models.py') }}
- name: Activate Conda Env
id: activate-conda-env
2022-10-25 21:27:38 +00:00
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ${{ env.CONDA_ENV_NAME }}
environment-file: ${{ matrix.environment-file }}
2022-10-25 21:27:38 +00:00
miniconda-version: latest
- name: set test prompt to main branch validation
id: set-test-prompt
2022-10-25 21:27:38 +00:00
if: ${{ github.ref == 'refs/heads/main' }}
run: echo "TEST_PROMPTS=tests/preflight_prompts.txt" >> $GITHUB_ENV
- name: set test prompt to development branch validation
id: set-test-prompt
2022-10-25 21:27:38 +00:00
if: ${{ github.ref == 'refs/heads/development' }}
run: echo "TEST_PROMPTS=tests/dev_prompts.txt" >> $GITHUB_ENV
- name: set test prompt to Pull Request validation
id: set-test-prompt
2022-10-25 21:27:38 +00:00
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/development' }}
run: echo "TEST_PROMPTS=tests/validate_pr_prompt.txt" >> $GITHUB_ENV
2022-10-25 21:27:38 +00:00
- name: Use Cached ${{ matrix.stable-diffusion-model-switch }}
2022-10-28 21:56:13 +00:00
id: cache-stable-diffusion-model
uses: actions/cache@v3
env:
cache-name: cache-sd-${{ matrix.stable-diffusion-model }}
with:
2022-10-29 05:35:43 +00:00
path: ${{ matrix.stable-diffusion-model-dl-path }}
2022-10-28 21:56:13 +00:00
key: ${{ env.cache-name }}
restore-keys: ${{ env.cache-name }}
2022-10-29 05:35:43 +00:00
- name: Download ${{ matrix.stable-diffusion-model-switch }}
id: download-stable-diffusion-model
if: ${{ steps.cache-stable-diffusion-model.outputs.cache-hit != 'true' }}
run: |
2022-10-25 21:27:38 +00:00
[[ -d models/ldm/stable-diffusion-v1 ]] \
|| mkdir -p models/ldm/stable-diffusion-v1
2022-10-29 05:35:43 +00:00
curl \
-H "Authorization: Bearer ${{ secrets.HUGGINGFACE_TOKEN }}" \
-o ${{ matrix.stable-diffusion-model-dl-path }} \
-L ${{ matrix.stable-diffusion-model }}
2022-10-25 21:27:38 +00:00
- name: run preload_models.py
id: run-preload-models
run: python scripts/preload_models.py
2022-10-25 21:27:38 +00:00
- name: Run the tests
id: run-tests
run: |
echo "!switch ${{ matrix.stable-diffusion-model-switch }}" > testprompts.txt
cat ${{ env.TEST_PROMPTS }} >> testprompts.txt
2022-10-25 21:27:38 +00:00
time python scripts/invoke.py \
--from_file testprompts.txt
2022-10-25 21:27:38 +00:00
- name: export conda env
id: export-conda-env
2022-10-25 21:27:38 +00:00
run: |
mkdir -p outputs/img-samples
conda env export --name ${{ env.CONDA_ENV_NAME }} > outputs/img-samples/environment-${{ runner.os }}-${{ runner.arch }}.yml
2022-10-25 21:27:38 +00:00
- name: Archive results
id: archive-results
uses: actions/upload-artifact@v3
with:
2022-10-29 06:08:15 +00:00
name: results_${{ matrix.os }}_${{ matrix.stable-diffusion-model-switch }}
path: outputs/img-samples