From 69e6d523018b45b0ffbf242d47e1558a58dc05e7 Mon Sep 17 00:00:00 2001 From: doctorpangloss <@hiddenswitch.com> Date: Sun, 25 Aug 2024 19:55:18 -0700 Subject: [PATCH] Fix tests --- README.md | 8 ++++-- comfy/text_encoders/long_clipl.py | 7 +++-- requirements-dev.txt | 1 + tests/README.md | 26 ------------------- .../server/routes/internal_routes_test.py | 2 +- 5 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 tests/README.md diff --git a/README.md b/README.md index 05041f906..82bcf5aa7 100644 --- a/README.md +++ b/README.md @@ -131,9 +131,13 @@ When using Windows, open the **Windows Powershell** app. Then observe you are at pip install --no-build-isolation git+https://github.com/hiddenswitch/ComfyUI.git ``` - For improved performance when using the language models on Windows, CUDA 12.1 and PyTorch 2.3.0, add: + For improved performance when using the language models on Windows, Python 3.11, CUDA 12.1 and PyTorch 2.4.0, add: ```shell - pip install flash-attn @ https://github.com/AppMana/appmana-comfyui-nodes-extramodels/releases/download/v0.0.0-flash_attn/flash_attn-2.5.9.post1-cp311-cp311-win_amd64.whl + pip install https://github.com/AppMana/appmana-comfyui-nodes-extramodels/releases/download/v0.0.0-flash_attn/flash_attn-2.6.3-cp311-cp311-win_amd64.whl + ``` + To enable `torchaudio` support on Windows, install it directly: + ```shell + pip install torchaudio==2.4.0+cu121 --index-url https://download.pytorch.org/whl/cu121 ``` Flash Attention as implemented in PyTorch is not functional on any version of Windows. ComfyUI will always run with "memory efficient attention" in practice on this platform. This is distinct from the `flash-attn` package.
**Advanced**: If you are running in Google Collab or another environment which has already installed `torch` for you, disable build isolation, and the package will recognize your currently installed torch. diff --git a/comfy/text_encoders/long_clipl.py b/comfy/text_encoders/long_clipl.py index 4677fb3b0..240891057 100644 --- a/comfy/text_encoders/long_clipl.py +++ b/comfy/text_encoders/long_clipl.py @@ -1,13 +1,16 @@ from comfy import sd1_clip import os +from comfy.component_model.files import get_path_as_dict + + class LongClipTokenizer_(sd1_clip.SDTokenizer): def __init__(self, embedding_directory=None, tokenizer_data={}): super().__init__(max_length=248, embedding_directory=embedding_directory, tokenizer_data=tokenizer_data) class LongClipModel_(sd1_clip.SDClipModel): - def __init__(self, device="cpu", dtype=None, model_options={}): - textmodel_json_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "long_clipl.json") + def __init__(self, device="cpu", dtype=None, model_options={}, textmodel_json_config=None): + textmodel_json_config = get_path_as_dict(textmodel_json_config, "long_clipl.json", package=__package__) super().__init__(device=device, textmodel_json_config=textmodel_json_config, return_projected_pooled=False, dtype=dtype, model_options=model_options) class LongClipTokenizer(sd1_clip.SD1Tokenizer): diff --git a/requirements-dev.txt b/requirements-dev.txt index bb291a9d8..4d50772eb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,7 @@ pytest pytest-asyncio pytest-mock +pytest-aiohttp websocket-client==1.6.1 PyInstaller testcontainers diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index ca3abad88..000000000 --- a/tests/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Automated Testing - -## Running tests locally - -Additional requirements for running tests: -``` -pip install .[dev] -``` -Run inference tests: -``` -pytest tests/inference -``` - -## Quality regression test -Compares images in 2 directories to ensure they are the same - -1) Run an inference test to save a directory of "ground truth" images -``` - pytest tests/inference --output_dir tests/inference/baseline -``` -2) Make code edits - -3) Run inference and quality comparison tests -``` -pytest -``` \ No newline at end of file diff --git a/tests/unit/server/routes/internal_routes_test.py b/tests/unit/server/routes/internal_routes_test.py index f3b1918ea..c31ded664 100644 --- a/tests/unit/server/routes/internal_routes_test.py +++ b/tests/unit/server/routes/internal_routes_test.py @@ -98,7 +98,7 @@ async def test_routes_added_to_app(aiohttp_client_factory, internal_routes): @pytest.mark.asyncio async def test_file_service_initialization(): - with patch('api_server.routes.internal.internal_routes.FileService') as MockFileService: + with patch('comfy.api_server.routes.internal.internal_routes.FileService') as MockFileService: # Create a mock instance mock_file_service_instance = MagicMock(spec=FileService) MockFileService.return_value = mock_file_service_instance