mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-02 07:25:07 -05:00
These were added as a hold-me-over for the nodes API changes, no longer needed. A followup commit will fix the nodes API to not rely on these.
69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
# Copyright (c) 2023 Lincoln D. Stein and the InvokeAI Team
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
import torch
|
|
from typing_extensions import Self
|
|
|
|
from invokeai.app.services.invoker import Invoker
|
|
|
|
from ..config import InvokeAIAppConfig
|
|
from ..download import DownloadQueueServiceBase
|
|
from ..events.events_base import EventServiceBase
|
|
from ..model_install import ModelInstallServiceBase
|
|
from ..model_load import ModelLoadServiceBase
|
|
from ..model_records import ModelRecordServiceBase
|
|
|
|
|
|
class ModelManagerServiceBase(ABC):
|
|
"""Abstract base class for the model manager service."""
|
|
|
|
# attributes:
|
|
# store: ModelRecordServiceBase = Field(description="An instance of the model record configuration service.")
|
|
# install: ModelInstallServiceBase = Field(description="An instance of the model install service.")
|
|
# load: ModelLoadServiceBase = Field(description="An instance of the model load service.")
|
|
|
|
@classmethod
|
|
@abstractmethod
|
|
def build_model_manager(
|
|
cls,
|
|
app_config: InvokeAIAppConfig,
|
|
model_record_service: ModelRecordServiceBase,
|
|
download_queue: DownloadQueueServiceBase,
|
|
events: EventServiceBase,
|
|
execution_device: torch.device,
|
|
) -> Self:
|
|
"""
|
|
Construct the model manager service instance.
|
|
|
|
Use it rather than the __init__ constructor. This class
|
|
method simplifies the construction considerably.
|
|
"""
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def store(self) -> ModelRecordServiceBase:
|
|
"""Return the ModelRecordServiceBase used to store and retrieve configuration records."""
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def load(self) -> ModelLoadServiceBase:
|
|
"""Return the ModelLoadServiceBase used to load models from their configuration records."""
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def install(self) -> ModelInstallServiceBase:
|
|
"""Return the ModelInstallServiceBase used to download and manipulate model files."""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def start(self, invoker: Invoker) -> None:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def stop(self, invoker: Invoker) -> None:
|
|
pass
|