InvokeAI/tests
psychedelicious 32a02b3329 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-20 15:15:21 +10:00
..
app refactor(events): use pydantic schemas for events 2024-05-20 15:15:21 +10:00
backend [util] Add generic torch device class (#6174) 2024-04-15 13:12:49 +00:00
fixtures test: clean up & fix tests 2024-03-01 10:42:33 +11:00
inpainting Rename default schedulers across the app 2023-05-12 03:44:20 +12:00
test_model_manager prevent vae: '' from crashing model 2023-08-10 17:33:04 -04:00
test_model_probe tests: add test for probing diffusers model variant type 2024-04-23 07:32:53 -04:00
__init__.py parent 9eed1919c2 2023-02-24 18:57:02 -08:00
conftest.py fix tests 2024-03-06 21:57:41 -05:00
dev_prompts.txt Added linux to the workflows (#463) 2022-09-16 17:46:57 -04:00
legacy_tests.sh Add back old dream.py as legacy_api.py 2022-10-12 20:35:56 -04:00
test_config.py fix(config): handle windows paths in invokeai.yaml migration for legacy_conf_dir 2024-04-02 08:06:59 -04:00
test_docs.py tidy(config): move config docstring builder to its script 2024-03-19 09:24:28 +11:00
test_graph_execution_state.py tests: add test for iterate execution order 2024-03-26 09:18:46 +11:00
test_invocation_cache_memory.py tests: add invocation cache tests 2024-03-06 08:14:12 -05:00
test_item_storage_memory.py chore(item-storage): improve types 2024-02-03 07:34:06 -05:00
test_model_hash.py feat(mm): rename "blake3" to "blake3_multi" 2024-03-22 08:26:36 +11:00
test_model_probe.py tests: add test for probing diffusers model variant type 2024-04-23 07:32:53 -04:00
test_model_search.py tidy(mm): ModelSearch cleanup 2024-03-10 12:09:47 +11:00
test_node_graph.py tidy(nodes): remove commented tests 2024-03-01 10:42:33 +11:00
test_nodes.py test: clean up & fix tests 2024-03-01 10:42:33 +11:00
test_object_serializer_disk.py tests: add object serializer test for dangling folders 2024-04-23 17:12:14 +10:00
test_path.py chore: ruff 2024-03-01 10:42:33 +11:00
test_profiler.py feat: add profiler util (#5601) 2024-01-31 10:51:57 +00:00
test_session_queue.py tidy(nodes): remove commented tests 2024-03-01 10:42:33 +11:00
test_sqlite_migrator.py feat(db): back up database before running migrations 2024-04-02 09:10:53 +11:00
validate_pr_prompt.txt fixes to env parsing, textual inversion & help text 2023-05-18 10:48:23 -04:00