From 0a7ddbb4a47021e73e8f5bf0ede0b3097ad5f49b Mon Sep 17 00:00:00 2001 From: Tai An Date: Sun, 30 Aug 2026 16:35:12 -0700 Subject: [PATCH] fix(tests): make the IP-Adapter slow test runnable again test_ip_adapter_unet_patch asks for a `model_installer` fixture that no longer exists and passes install_and_load_model(model_installer=...), whose parameter has been `model_manager` since the model-manager refactor. It also asks for `torch_device`, which is defined in invokeai/backend/util/test_utils.py but is not imported into any conftest, so pytest cannot resolve it either. - use the `mm2_model_manager` fixture (already star-imported into tests/conftest.py) and pass it as `model_manager=` - import `torch_device` in tests/conftest.py, which is what the comment at the top of that file already claims happens, and is the convention the file documents for fixtures that trip F401/F811 - drop `model_installer` from that comment and fix the stale `mm2_model_manager` arg name in the install_and_load_model docstring The test is @pytest.mark.slow, excluded by the default `-m "not slow"`, which is why this went unnoticed. --- invokeai/backend/util/test_utils.py | 2 +- tests/backend/ip_adapter/test_ip_adapter.py | 6 +++--- tests/conftest.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/invokeai/backend/util/test_utils.py b/invokeai/backend/util/test_utils.py index a64919ca4b5..609790b8a40 100644 --- a/invokeai/backend/util/test_utils.py +++ b/invokeai/backend/util/test_utils.py @@ -33,7 +33,7 @@ def install_and_load_model( This is intended as a utility function for tests. Args: - mm2_model_manager (ModelManagerServiceBase): The model manager + model_manager (ModelManagerServiceBase): The model manager model_path_id_or_url (Union[str, Path]): The path, HF ID, URL, etc. where the model can be installed from if it is not already installed. model_name (str): The model name, forwarded to ModelManager.get_model(...). diff --git a/tests/backend/ip_adapter/test_ip_adapter.py b/tests/backend/ip_adapter/test_ip_adapter.py index 87b696c5342..c2d6a161c2f 100644 --- a/tests/backend/ip_adapter/test_ip_adapter.py +++ b/tests/backend/ip_adapter/test_ip_adapter.py @@ -48,10 +48,10 @@ def build_dummy_sd15_unet_input(torch_device): ], ) @pytest.mark.slow -def test_ip_adapter_unet_patch(model_params, model_installer, torch_device): +def test_ip_adapter_unet_patch(model_params, mm2_model_manager, torch_device): """Smoke test that IP-Adapter weights can be loaded and used to patch a UNet.""" ip_adapter_info = install_and_load_model( - model_installer=model_installer, + model_manager=mm2_model_manager, model_path_id_or_url=model_params["ip_adapter_model_id"], model_name=model_params["ip_adapter_model_name"], base_model=model_params["base_model"], @@ -59,7 +59,7 @@ def test_ip_adapter_unet_patch(model_params, model_installer, torch_device): ) unet_info = install_and_load_model( - model_installer=model_installer, + model_manager=mm2_model_manager, model_path_id_or_url=model_params["unet_model_id"], model_name=model_params["unet_model_name"], base_model=model_params["base_model"], diff --git a/tests/conftest.py b/tests/conftest.py index bb8afd1d8de..d105c017741 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,7 @@ # without needing to explicitly import them. (https://docs.pytest.org/en/6.2.x/fixture.html) -# We import the model_installer and torch_device fixtures here so that they can be used by all tests. Flake8 does not +# We import the torch_device fixture here so that it can be used by all tests. Flake8 does not # play well with fixtures (F401 and F811), so this is cleaner than importing in all files that use these fixtures. import logging import shutil @@ -32,6 +32,7 @@ from invokeai.app.services.video_records.video_records_sqlite import SqliteVideoRecordStorage from invokeai.app.services.workflow_records.workflow_records_sqlite import SqliteWorkflowRecordsStorage from invokeai.backend.util.logging import InvokeAILogger +from invokeai.backend.util.test_utils import torch_device # noqa: F401 from tests.backend.model_manager.model_manager_fixtures import * # noqa: F403 from tests.fixtures.sqlite_database import create_mock_sqlite_database # noqa: F401 from tests.test_nodes import TestEventService