mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 03:05:11 -05:00
- Replace legacy model manager service with the v2 manager. - Update invocations to use new load interface. - Fixed many but not all type checking errors in the invocations. Most were unrelated to model manager - Updated routes. All the new routes live under the route tag `model_manager_v2`. To avoid confusion with the old routes, they have the URL prefix `/api/v2/models`. The old routes have been de-registered. - Added a pytest for the loader. - Updated documentation in contributing/MODEL_MANAGER.md
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
# Copyright (c) 2023 Lincoln D. Stein and the InvokeAI Team
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
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
|
|
from ..shared.sqlite.sqlite_database import SqliteDatabase
|
|
|
|
|
|
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,
|
|
db: SqliteDatabase,
|
|
download_queue: DownloadQueueServiceBase,
|
|
events: EventServiceBase,
|
|
) -> 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
|