mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-04-30 19:21:21 +00:00
Fix CQ tests (#141)
* Make test client run on cpu * test on cpu try fix device try fix device try fix device * Use real SD1.5 model for testing * ckpt nits * Remove coverage calls
This commit is contained in:
82
.github/workflows/run_tests.yaml
vendored
Normal file
82
.github/workflows/run_tests.yaml
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: tests on CPU
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up Python 3.10
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.10.6
|
||||||
|
cache: pip
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/requirements*txt
|
||||||
|
launch.py
|
||||||
|
- name: Cache models
|
||||||
|
id: cache-models
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: models
|
||||||
|
key: "2023-12-30"
|
||||||
|
- name: Install test dependencies
|
||||||
|
run: pip install wait-for-it -r requirements-test.txt
|
||||||
|
env:
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
|
PIP_PROGRESS_BAR: "off"
|
||||||
|
- name: Setup environment
|
||||||
|
run: python launch.py --skip-torch-cuda-test --exit
|
||||||
|
env:
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
|
PIP_PROGRESS_BAR: "off"
|
||||||
|
TORCH_INDEX_URL: https://download.pytorch.org/whl/cpu
|
||||||
|
WEBUI_LAUNCH_LIVE_OUTPUT: "1"
|
||||||
|
PYTHONUNBUFFERED: "1"
|
||||||
|
- name: Print installed packages
|
||||||
|
run: pip freeze
|
||||||
|
- name: Download models
|
||||||
|
run: |
|
||||||
|
declare -a urls=(
|
||||||
|
"https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/realisticVisionV51_v51VAE.safetensors"
|
||||||
|
)
|
||||||
|
for url in "${urls[@]}"; do
|
||||||
|
filename="models/Stable-diffusion/${url##*/}" # Extracts the last part of the URL
|
||||||
|
if [ ! -f "$filename" ]; then
|
||||||
|
curl -Lo "$filename" "$url"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
- name: Start test server
|
||||||
|
run: >
|
||||||
|
python -m coverage run
|
||||||
|
--data-file=.coverage.server
|
||||||
|
launch.py
|
||||||
|
--skip-prepare-environment
|
||||||
|
--skip-torch-cuda-test
|
||||||
|
--test-server
|
||||||
|
--do-not-download-clip
|
||||||
|
--no-half
|
||||||
|
--disable-opt-split-attention
|
||||||
|
--always-cpu
|
||||||
|
--api-server-stop
|
||||||
|
--ckpt models/Stable-diffusion/realisticVisionV51_v51VAE.safetensors
|
||||||
|
2>&1 | tee output.txt &
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
wait-for-it --service 127.0.0.1:7860 -t 20
|
||||||
|
python -m pytest -vv --junitxml=test/results.xml --cov . --cov-report=xml --verify-base-url test
|
||||||
|
- name: Kill test server
|
||||||
|
if: always()
|
||||||
|
run: curl -vv -XPOST http://127.0.0.1:7860/sdapi/v1/server-stop && sleep 10
|
||||||
|
- name: Upload main app output
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: output
|
||||||
|
path: output.txt
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -39,3 +39,5 @@ notification.mp3
|
|||||||
/package-lock.json
|
/package-lock.json
|
||||||
/.coverage*
|
/.coverage*
|
||||||
/test/test_outputs
|
/test/test_outputs
|
||||||
|
/test/results.xml
|
||||||
|
coverage.xml
|
||||||
@@ -5,6 +5,7 @@ from ldm_patched.modules.args_parser import args
|
|||||||
import ldm_patched.modules.utils
|
import ldm_patched.modules.utils
|
||||||
import torch
|
import torch
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
class VRAMState(Enum):
|
class VRAMState(Enum):
|
||||||
DISABLED = 0 #No vram present: no need to move models to vram
|
DISABLED = 0 #No vram present: no need to move models to vram
|
||||||
@@ -58,7 +59,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if args.always_cpu:
|
if args.always_cpu or os.environ.get("FORGE_CQ_TEST", ""):
|
||||||
cpu_state = CPUState.CPU
|
cpu_state = CPUState.CPU
|
||||||
|
|
||||||
def is_intel_xpu():
|
def is_intel_xpu():
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ def pytest_configure(config):
|
|||||||
# We don't want to fail on Py.test command line arguments being
|
# We don't want to fail on Py.test command line arguments being
|
||||||
# parsed by webui:
|
# parsed by webui:
|
||||||
os.environ.setdefault("IGNORE_CMD_ARGS_ERRORS", "1")
|
os.environ.setdefault("IGNORE_CMD_ARGS_ERRORS", "1")
|
||||||
|
os.environ.setdefault("FORGE_CQ_TEST", "1")
|
||||||
|
|
||||||
|
|
||||||
def file_to_base64(filename):
|
def file_to_base64(filename):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from PIL import Image
|
|||||||
|
|
||||||
@pytest.mark.usefixtures("initialize")
|
@pytest.mark.usefixtures("initialize")
|
||||||
@pytest.mark.parametrize("restorer_name", ["gfpgan", "codeformer"])
|
@pytest.mark.parametrize("restorer_name", ["gfpgan", "codeformer"])
|
||||||
|
@pytest.mark.skip # Skip for forge.
|
||||||
def test_face_restorers(restorer_name):
|
def test_face_restorers(restorer_name):
|
||||||
from modules import shared
|
from modules import shared
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ def test_txt2img_with_tiling_performed(url_txt2img, simple_txt2img_request):
|
|||||||
assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
|
assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip # Skip for forge.
|
||||||
def test_txt2img_with_restore_faces_performed(url_txt2img, simple_txt2img_request):
|
def test_txt2img_with_restore_faces_performed(url_txt2img, simple_txt2img_request):
|
||||||
simple_txt2img_request["restore_faces"] = True
|
simple_txt2img_request["restore_faces"] = True
|
||||||
assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
|
assert requests.post(url_txt2img, json=simple_txt2img_request).status_code == 200
|
||||||
|
|||||||
Reference in New Issue
Block a user