mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
0a09f84b07
This change enhances the invocation cache logic to delete cache entries when the resources to which they refer are deleted. For example, a cached output may refer to "some_image.png". If that image is deleted, and this particular cache entry is later retrieved by a node, that node's successors will receive references to the now non-existent "some_image.png". When they attempt to use that image, they will fail. To resolve this, we need to invalidate the cache when the resources to which it refers are deleted. Two options: - Invalidate the whole cache on every image/latents/etc delete - Selectively invalidate cache entries when their resources are deleted Node outputs can be any shape, with any number of resource references in arbitrarily nested pydantic models. Traversing that structure to identify resources is not trivial. But invalidating the whole cache is a bit heavy-handed. It would be nice to be more selective. Simple solution: - Invocation outputs' resource references are always string identifiers - like the image's or latents' name - Invocation outputs can be stringified, which includes said identifiers - When the invocation is cached, we store the stringified output alongside the "live" output classes - When a resource is deleted, pass its identifier to the cache service, which can then invalidate any cache entries that refer to it The images and latents storage services have been outfitted with `on_deleted()` callbacks, and the cache service registers itself to handle those events. This logic was copied from `ItemStorageABC`. `on_changed()` callback are also added to the images and latents services, though these are not currently used. Just following the existing pattern. |
||
---|---|---|
.. | ||
config | ||
invocation_cache | ||
models | ||
session_processor | ||
session_queue | ||
shared | ||
__init__.py | ||
board_image_record_storage.py | ||
board_images.py | ||
board_record_storage.py | ||
boards.py | ||
default_graphs.py | ||
events.py | ||
graph.py | ||
image_file_storage.py | ||
image_record_storage.py | ||
images.py | ||
invocation_queue.py | ||
invocation_services.py | ||
invocation_stats.py | ||
invoker.py | ||
item_storage.py | ||
latent_storage.py | ||
model_manager_service.py | ||
processor.py | ||
resource_name.py | ||
sqlite.py | ||
thread.py | ||
urls.py |