InvokeAI/invokeai/app/api/routers
psychedelicious 9bd78823a3 refactor(events): use pydantic schemas for events
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.
2024-05-27 09:06:02 +10:00
..
app_info.py fix(nodes): fix nsfw checker model download 2024-05-14 07:23:38 +10:00
board_images.py Resolving merge conflicts for flake8 2023-08-18 15:52:04 +10:00
boards.py feat: refactor services folder/module structure 2023-10-12 12:15:06 -04:00
download_queue.py fix a number of typechecking errors 2024-03-01 10:42:33 +11:00
images.py feat(api): downgrade metadata parse warnings to debug 2024-05-23 22:48:34 +10:00
model_manager.py refactor(events): use pydantic schemas for events 2024-05-27 09:06:02 +10:00
session_queue.py feat(app): update queue item's session on session completion 2024-05-24 08:59:49 +10:00
utilities.py feat(api): add max_prompts constraints 2023-12-29 08:26:14 -05:00
workflows.py feat: workflow library (#5148) 2023-12-09 09:48:38 +11:00