Skip to content

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.

test: make install rollback race filesystem-independent

Josh Corbett1c0ed4b488f3
diff --git a/tests/app/services/model_install/test_model_install.py b/tests/app/services/model_install/test_model_install.py
index c76cc4ce6f..421098f5c6 100644
--- a/tests/app/services/model_install/test_model_install.py
+++ b/tests/app/services/model_install/test_model_install.py
@@ -665,9 +665,19 @@ def test_directory_install_rollback_race_preserves_both_source_artifacts(
mm2_app_config: InvokeAIAppConfig,
monkeypatch: pytest.MonkeyPatch,
) -> None:
+ real_iterdir = Path.iterdir
+
+ def files_first(path: Path):
+ items = real_iterdir(path)
+ if path == diffusers_dir:
+ # Move a file before the locked directory, regardless of filesystem enumeration order.
+ return iter(sorted(items, key=lambda item: (not item.is_file(), item.name)))
+ return items
+
+ monkeypatch.setattr(Path, "iterdir", files_first)
items = list(diffusers_dir.iterdir())
+ first_item = next(path for path in items if path.is_file())
locked_item = items[-1]
- first_item = next(path for path in items[:-1] if path.is_file())
original_bytes = first_item.read_bytes()
real_move = shutil.move
real_rename_noreplace = ModelInstallService._rename_noreplace