mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(nodes): use forward declarations for InvocationServices
Also use `TYPE_CHECKING` to get IDE hints.
This commit is contained in:
parent
6f3c6ddf3f
commit
37cdd91f5d
@ -1,18 +1,17 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) and the InvokeAI Team
|
||||||
|
from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from logging import Logger
|
|
||||||
|
|
||||||
from invokeai.app.services.images import ImageService
|
|
||||||
from invokeai.backend import ModelManager
|
|
||||||
from .events import EventServiceBase
|
|
||||||
from .latent_storage import LatentsStorageBase
|
|
||||||
from .restoration_services import RestorationServices
|
|
||||||
from .invocation_queue import InvocationQueueABC
|
|
||||||
from .item_storage import ItemStorageABC
|
|
||||||
from .config import InvokeAISettings
|
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
from logging import Logger
|
||||||
|
from invokeai.app.services.images import ImageService
|
||||||
|
from invokeai.backend import ModelManager
|
||||||
|
from invokeai.app.services.events import EventServiceBase
|
||||||
|
from invokeai.app.services.latent_storage import LatentsStorageBase
|
||||||
|
from invokeai.app.services.restoration_services import RestorationServices
|
||||||
|
from invokeai.app.services.invocation_queue import InvocationQueueABC
|
||||||
|
from invokeai.app.services.item_storage import ItemStorageABC
|
||||||
|
from invokeai.app.services.config import InvokeAISettings
|
||||||
from invokeai.app.services.graph import GraphExecutionState, LibraryGraph
|
from invokeai.app.services.graph import GraphExecutionState, LibraryGraph
|
||||||
from invokeai.app.services.invoker import InvocationProcessorABC
|
from invokeai.app.services.invoker import InvocationProcessorABC
|
||||||
|
|
||||||
@ -20,32 +19,33 @@ if TYPE_CHECKING:
|
|||||||
class InvocationServices:
|
class InvocationServices:
|
||||||
"""Services that can be used by invocations"""
|
"""Services that can be used by invocations"""
|
||||||
|
|
||||||
events: EventServiceBase
|
# TODO: Just forward-declared everything due to circular dependencies. Fix structure.
|
||||||
latents: LatentsStorageBase
|
events: "EventServiceBase"
|
||||||
queue: InvocationQueueABC
|
latents: "LatentsStorageBase"
|
||||||
model_manager: ModelManager
|
queue: "InvocationQueueABC"
|
||||||
restoration: RestorationServices
|
model_manager: "ModelManager"
|
||||||
configuration: InvokeAISettings
|
restoration: "RestorationServices"
|
||||||
images: ImageService
|
configuration: "InvokeAISettings"
|
||||||
|
images: "ImageService"
|
||||||
|
|
||||||
# NOTE: we must forward-declare any types that include invocations, since invocations can use services
|
# NOTE: we must forward-declare any types that include invocations, since invocations can use services
|
||||||
graph_library: ItemStorageABC["LibraryGraph"]
|
graph_library: "ItemStorageABC"["LibraryGraph"]
|
||||||
graph_execution_manager: ItemStorageABC["GraphExecutionState"]
|
graph_execution_manager: "ItemStorageABC"["GraphExecutionState"]
|
||||||
processor: "InvocationProcessorABC"
|
processor: "InvocationProcessorABC"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
model_manager: ModelManager,
|
model_manager: "ModelManager",
|
||||||
events: EventServiceBase,
|
events: "EventServiceBase",
|
||||||
logger: Logger,
|
logger: "Logger",
|
||||||
latents: LatentsStorageBase,
|
latents: "LatentsStorageBase",
|
||||||
images: ImageService,
|
images: "ImageService",
|
||||||
queue: InvocationQueueABC,
|
queue: "InvocationQueueABC",
|
||||||
graph_library: ItemStorageABC["LibraryGraph"],
|
graph_library: "ItemStorageABC"["LibraryGraph"],
|
||||||
graph_execution_manager: ItemStorageABC["GraphExecutionState"],
|
graph_execution_manager: "ItemStorageABC"["GraphExecutionState"],
|
||||||
processor: "InvocationProcessorABC",
|
processor: "InvocationProcessorABC",
|
||||||
restoration: RestorationServices,
|
restoration: "RestorationServices",
|
||||||
configuration: InvokeAISettings = None,
|
configuration: "InvokeAISettings",
|
||||||
):
|
):
|
||||||
self.model_manager = model_manager
|
self.model_manager = model_manager
|
||||||
self.events = events
|
self.events = events
|
||||||
|
Loading…
Reference in New Issue
Block a user