From 20db93b9017d1ab1dd70cc587a647c42c2791ed7 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:51:06 +1100 Subject: [PATCH] fix(mm): check for presence of invoker before emitting model load event The model loader emits events. During testing, it doesn't have access to a fully-mocked events service, so the test fails when attempting to call a nonexistent method. There was a check for this previously, but I accidentally removed it. Restored. --- invokeai/app/services/model_load/model_load_default.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/invokeai/app/services/model_load/model_load_default.py b/invokeai/app/services/model_load/model_load_default.py index 1d6423af5a..300cd982e7 100644 --- a/invokeai/app/services/model_load/model_load_default.py +++ b/invokeai/app/services/model_load/model_load_default.py @@ -58,7 +58,10 @@ class ModelLoadService(ModelLoadServiceBase): :param submodel: For main (pipeline models), the submodel to fetch. """ - self._invoker.services.events.emit_model_load_started(model_config, submodel_type) + # We don't have an invoker during testing + # TODO(psyche): Mock this method on the invoker in the tests + if hasattr(self, "_invoker"): + self._invoker.services.events.emit_model_load_started(model_config, submodel_type) implementation, model_config, submodel_type = self._registry.get_implementation(model_config, submodel_type) # type: ignore loaded_model: LoadedModel = implementation( @@ -68,6 +71,7 @@ class ModelLoadService(ModelLoadServiceBase): convert_cache=self._convert_cache, ).load_model(model_config, submodel_type) - self._invoker.services.events.emit_model_load_started(model_config, submodel_type) + if hasattr(self, "_invoker"): + self._invoker.services.events.emit_model_load_started(model_config, submodel_type) return loaded_model