mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
725c03cf87
Consolidate graph processing logic into session processor. With graphs as the unit of work, and the session queue distributing graphs, we no longer need the invocation queue or processor. Instead, the session processor dequeues the next session and processes it in a simple loop, greatly simplifying the app. - Remove `graph_execution_manager` service. - Remove `queue` (invocation queue) service. - Remove `processor` (invocation processor) service. - Remove queue-related logic from `Invoker`. It now only starts and stops the services, providing them with access to other services. - Remove unused `invocation_retrieval_error` and `session_retrieval_error` events, these are no longer needed. - Clean up stats service now that it is less coupled to the rest of the app. - Refactor cancellation logic - cancellations now originate from session queue (i.e. HTTP cancel endpoint) and are emitted as events. Processor gets the events and sets the canceled event. Access to this event is provided to the invocation context for e.g. the step callback. - Remove `sessions` router; it provided access to `graph_executions` but that no longer exists.
83 lines
3.5 KiB
Python
83 lines
3.5 KiB
Python
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from invokeai.app.services.object_serializer.object_serializer_base import ObjectSerializerBase
|
|
|
|
if TYPE_CHECKING:
|
|
from logging import Logger
|
|
|
|
import torch
|
|
|
|
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import ConditioningFieldData
|
|
|
|
from .board_image_records.board_image_records_base import BoardImageRecordStorageBase
|
|
from .board_images.board_images_base import BoardImagesServiceABC
|
|
from .board_records.board_records_base import BoardRecordStorageBase
|
|
from .boards.boards_base import BoardServiceABC
|
|
from .config import InvokeAIAppConfig
|
|
from .download import DownloadQueueServiceBase
|
|
from .events.events_base import EventServiceBase
|
|
from .image_files.image_files_base import ImageFileStorageBase
|
|
from .image_records.image_records_base import ImageRecordStorageBase
|
|
from .images.images_base import ImageServiceABC
|
|
from .invocation_cache.invocation_cache_base import InvocationCacheBase
|
|
from .invocation_stats.invocation_stats_base import InvocationStatsServiceBase
|
|
from .model_manager.model_manager_base import ModelManagerServiceBase
|
|
from .names.names_base import NameServiceBase
|
|
from .session_processor.session_processor_base import SessionProcessorBase
|
|
from .session_queue.session_queue_base import SessionQueueBase
|
|
from .urls.urls_base import UrlServiceBase
|
|
from .workflow_records.workflow_records_base import WorkflowRecordsStorageBase
|
|
|
|
|
|
class InvocationServices:
|
|
"""Services that can be used by invocations"""
|
|
|
|
def __init__(
|
|
self,
|
|
board_images: "BoardImagesServiceABC",
|
|
board_image_records: "BoardImageRecordStorageBase",
|
|
boards: "BoardServiceABC",
|
|
board_records: "BoardRecordStorageBase",
|
|
configuration: "InvokeAIAppConfig",
|
|
events: "EventServiceBase",
|
|
images: "ImageServiceABC",
|
|
image_files: "ImageFileStorageBase",
|
|
image_records: "ImageRecordStorageBase",
|
|
logger: "Logger",
|
|
model_manager: "ModelManagerServiceBase",
|
|
download_queue: "DownloadQueueServiceBase",
|
|
performance_statistics: "InvocationStatsServiceBase",
|
|
session_queue: "SessionQueueBase",
|
|
session_processor: "SessionProcessorBase",
|
|
invocation_cache: "InvocationCacheBase",
|
|
names: "NameServiceBase",
|
|
urls: "UrlServiceBase",
|
|
workflow_records: "WorkflowRecordsStorageBase",
|
|
tensors: "ObjectSerializerBase[torch.Tensor]",
|
|
conditioning: "ObjectSerializerBase[ConditioningFieldData]",
|
|
):
|
|
self.board_images = board_images
|
|
self.board_image_records = board_image_records
|
|
self.boards = boards
|
|
self.board_records = board_records
|
|
self.configuration = configuration
|
|
self.events = events
|
|
self.images = images
|
|
self.image_files = image_files
|
|
self.image_records = image_records
|
|
self.logger = logger
|
|
self.model_manager = model_manager
|
|
self.download_queue = download_queue
|
|
self.performance_statistics = performance_statistics
|
|
self.session_queue = session_queue
|
|
self.session_processor = session_processor
|
|
self.invocation_cache = invocation_cache
|
|
self.names = names
|
|
self.urls = urls
|
|
self.workflow_records = workflow_records
|
|
self.tensors = tensors
|
|
self.conditioning = conditioning
|