mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
421440cae0
Makes graph validation logic more rigorous, validating graphs when they are created as part of a session or batch. `validate_self()` method added to `Graph` model. It does all the validation that `is_valid()` did, plus a few extras: - unique `node.id` values across graph - node ids match their key in `Graph.nodes` - recursively validate subgraphs - validate all edges - validate graph is acyclical The new method is required because `is_valid()` just returned a boolean. That behaviour is retained, but `validate_self()` now raises appropriate exceptions for validation errors. This are then surfaced to the client. The function is named `validate_self()` because pydantic reserves `validate()`. There are two main places where graphs are created - in batches and in sessions. Field validators are added to each of these for their `graph` fields, which call the new validation logic. **Closes #4744** In this issue, a batch is enqueued with an invalid graph. The output field is typed as optional while the input field is required. The field types themselves are not relevant - this change addresses the case where an invalid graph was created. The mismatched types problem is not noticed until we attempt to invoke the graph, because the graph was never *fully* validated. An error is raised during the call to `graph_execution_state.next()` in `invoker.py`. This function prepares the edges and validates them, raising an exception due to the mismatched types. This exception is caught by the session processor, but it doesn't handle this situation well - the graph is not marked as having an error and the queue item status is never changed. The queue item is therefore forever `in_progress`, so no new queue items are popped - the app won't do anything until the queue item is canceled manually. This commit addresses this by preventing invalid graphs from being created in the first place, addressing a substantial number of fail cases. |
||
---|---|---|
.. | ||
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 |