diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 3cb681e33..970ab3588 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -281,7 +281,7 @@ jobs: - name: Start ComfyUI Web Service if: matrix.test-suite == 'comfy' run: | - docker exec -w /app/ComfyUI -d ${{ env.CONTAINER_NAME }} sh -c "python3 /app/ComfyUI/main.py --port 8188 --extra-model-paths-config /src/onediff/tests/comfyui/extra_model_paths.yaml > /app/ComfyUI/onediff_comfyui.log 2>&1" + docker exec -w /app/ComfyUI -d ${{ env.CONTAINER_NAME }} sh -c "COMFYUI_ONEDIFF_SAVE_GRAPH_DIR=/app/ComfyUI/output python3 /app/ComfyUI/main.py --port 8188 --extra-model-paths-config /src/onediff/tests/comfyui/extra_model_paths.yaml --input-directory /share_nfs/hf_models/comfyui_resources/input > /app/ComfyUI/onediff_comfyui.log 2>&1" sleep 30 # print to check if comfy is launched successfully - run: docker exec ${{ env.CONTAINER_NAME }} ps aux @@ -300,7 +300,7 @@ jobs: run_comfy_test "workflows/sdxl-unet-speedup-graph-saver.json" 200 run_comfy_test "workflows/sdxl-control-lora-speedup.json" 200 - run_comfy_test "/share_nfs/hf_models/comfyui_resources/workflows/ipadapter_advanced.json" 200 + run_comfy_test "/share_nfs/hf_models/comfyui_resources/workflows/ComfyUI_IPAdapter_plus" 500 run_comfy_test "/share_nfs/hf_models/comfyui_resources/workflows/deep-cache.json" 600 run_comfy_test "/share_nfs/hf_models/comfyui_resources/workflows/deep-cache-with-lora.json" 800 # run_comfy_test "workflows/text-to-video-speedup.json" 5000 diff --git a/tests/comfyui/test_by_ui.py b/tests/comfyui/test_by_ui.py index 9ee92836a..2d1226af0 100644 --- a/tests/comfyui/test_by_ui.py +++ b/tests/comfyui/test_by_ui.py @@ -40,7 +40,9 @@ """ import argparse import os +from pathlib import Path import time +from typing import List, Union from PIL import Image from selenium import webdriver @@ -53,7 +55,11 @@ def parse_args(): parser = argparse.ArgumentParser(description="Test ComfyUI workflow by Selenium.") parser.add_argument( - "-w", "--workflow", type=str, required=True, help="Workflow file", + "-w", + "--workflow", + type=str, + required=True, + help="Workflow file or directory containing JSON files.", ) parser.add_argument( "-t", "--timeout", type=int, default="200", @@ -81,6 +87,16 @@ def extract_metadata_from_png(png_file_path): return metadata +def process_workflow(workflow: Union[str, Path]) -> List[Path]: + workflow_path = Path(workflow) + if workflow_path.is_file(): + return [workflow_path] + elif workflow_path.is_dir(): + return list(workflow_path.glob("*.json")) + else: + return [] + + def read_workflow_json(filename) -> str: _, extension = os.path.splitext(filename) if extension.endswith("json"): @@ -158,34 +174,35 @@ def launch_prompt(driver): time.sleep(0.1) start_time = time.time() - wait_until_app_ready(driver) + for workflow_path in process_workflow(args.workflow): + wait_until_app_ready(driver) - print("clear the workflow...") - clear_curernt_workflow(driver) - print("workflow cleard") + print("clear the workflow...") + clear_curernt_workflow(driver) + print("workflow cleard") - print("load the target workflow...") - load_workflow_graph(driver, read_workflow_json(args.workflow)) - print(f"{args.workflow} loaded") + print("load the target workflow...") + load_workflow_graph(driver, read_workflow_json(workflow_path)) + print(f"{workflow_path} loaded") - print("check the nodes type of workflow...") - check_graph_node_types(driver) - print(f"{args.workflow} workflow checked") + print("check the nodes type of workflow...") + check_graph_node_types(driver) + print(f"{workflow_path} workflow checked") - print(f"launch the queue prompt (timeout: {args.timeout}s) ...") - launch_and_wait(driver, timeout=args.timeout) + print(f"launch the queue prompt (timeout: {args.timeout}s) ...") + launch_and_wait(driver, timeout=args.timeout) - duration = time.time() - start_time - print( - f"{args.workflow} has finished, time elapsed: {duration:.1f}" - ) - - if duration < 2: - raise ValueError("Execution duration is too short, possible error in workflow execution") + duration = time.time() - start_time + print(f"{workflow_path} has finished, time elapsed: {duration:.1f}") + + if duration < 2: + raise ValueError( + "Execution duration is too short, possible error in workflow execution" + ) - print(f"check if error occurs...") - check_error_occurs(driver) - print(f"no error occurs when executing workflow") + print(f"check if error occurs...") + check_error_occurs(driver) + print(f"no error occurs when executing workflow") except TimeoutException: print("Time out") exit(1)