mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
32a02b3329
Our events handling and implementation has a couple pain points: - Adding or removing data from event payloads requires changes wherever the events are dispatched from. - We have no type safety for events and need to rely on string matching and dict access when interacting with events. - Frontend types for socket events must be manually typed. This has caused several bugs. `fastapi-events` has a neat feature where you can create a pydantic model as an event payload, give it an `__event_name__` attr, and then dispatch the model directly. This allows us to eliminate a layer of indirection and some unpleasant complexity: - Event handler callbacks get type hints for their event payloads, and can use `isinstance` on them if needed. - Event payload construction is now the responsibility of the event itself (a pydantic model), not the service. Every event model has a `build` class method, encapsulating this logic. The build methods are provided as few args as possible. For example, `InvocationStartedEvent.build()` gets the invocation instance and queue item, and can choose the data it wants to include in the event payload. - Frontend event types may be autogenerated from the OpenAPI schema. We use the payload registry feature of `fastapi-events` to collect all payload models into one place, making it trivial to keep our schema and frontend types in sync. This commit moves the backend over to this improved event handling setup. |
||
---|---|---|
.. | ||
app | ||
backend | ||
fixtures | ||
inpainting | ||
test_model_manager | ||
test_model_probe | ||
__init__.py | ||
conftest.py | ||
dev_prompts.txt | ||
legacy_tests.sh | ||
test_config.py | ||
test_docs.py | ||
test_graph_execution_state.py | ||
test_invocation_cache_memory.py | ||
test_item_storage_memory.py | ||
test_model_hash.py | ||
test_model_probe.py | ||
test_model_search.py | ||
test_node_graph.py | ||
test_nodes.py | ||
test_object_serializer_disk.py | ||
test_path.py | ||
test_profiler.py | ||
test_session_queue.py | ||
test_sqlite_migrator.py | ||
validate_pr_prompt.txt |