Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test: pin the device in the generation-wait tests
Lincoln Stein6972e03e8e0f
diff --git a/tests/app/services/image_index/test_image_index_service.py b/tests/app/services/image_index/test_image_index_service.pyindex d16c1ce950..d30df992e2 100644--- a/tests/app/services/image_index/test_image_index_service.py+++ b/tests/app/services/image_index/test_image_index_service.py@@ -6,6 +6,7 @@ from typing import Callableimport numpy as npimport pytest+import torchfrom PIL import Imagefrom invokeai.app.services.config.config_default import InvokeAIAppConfig@@ -22,6 +23,7 @@ from invokeai.app.services.image_records.image_records_sqlite import SqliteImagefrom invokeai.app.services.images.images_common import image_record_to_dtofrom invokeai.app.services.images.images_default import ImageServicefrom invokeai.app.services.shared.sqlite.sqlite_database import SqliteDatabase+from invokeai.backend.util.devices import TorchDevicefrom invokeai.backend.util.logging import InvokeAILoggerfrom tests.fixtures.sqlite_database import create_mock_sqlite_databasefrom tests.test_nodes import TestEventService@@ -110,6 +112,18 @@ def service() -> ImageIndexService:svc.stop()+def accelerator_host(monkeypatch: pytest.MonkeyPatch) -> None:+ """Pretend the host has a non-CPU device.++ With no `image_index_device` override, CPU mode is decided by autodetection, so on a+ CPU-only machine — every linux-cpu and windows-cpu CI runner — the generation wait is+ skipped entirely. Tests covering that wait have to pin the device or they assert nothing+ there while still passing.+ """+ monkeypatch.setattr(TorchDevice, "choose_torch_device", staticmethod(lambda: torch.device("cuda")))++def _save_image(image_records: SqliteImageRecordStorage,image_name: str,@@ -545,6 +559,7 @@ def test_worker_waits_for_generation_to_finish_when_not_on_cpu(image_records: SqliteImageRecordStorage,images_service: ImageService,index_records: ImageIndexRecordsSqlite,+ accelerator_host: None,) -> None:"""The VRAM contract: off the CPU path, embedding must pause while a generation runs.@@ -573,6 +588,7 @@ def test_generation_wait_does_not_block_shutdown(image_records: SqliteImageRecordStorage,images_service: ImageService,index_records: ImageIndexRecordsSqlite,+ accelerator_host: None,) -> None:"""A generation that never ends must not stop the worker from honouring stop()."""session_queue = SimpleNamespace(get_queue_status=lambda queue_id: SimpleNamespace(in_progress=1))