mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(config): removed extraneous ABC
We don't need separate implementations for this class, let's not complicate it with an ABC
This commit is contained in:
parent
b612c73954
commit
e39f035264
@ -4,7 +4,6 @@
|
||||
Utility class for migrating among versions of the InvokeAI app config schema.
|
||||
"""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Callable, List, TypeVar
|
||||
|
||||
from packaging.version import Version
|
||||
@ -13,29 +12,6 @@ from pydantic import BaseModel, ConfigDict, field_validator
|
||||
AppConfigDict = TypeVar("AppConfigDict", bound=dict[str, Any])
|
||||
|
||||
|
||||
class ConfigMigratorBase(ABC):
|
||||
"""This class allows migrators to register their input and output versions."""
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def register(
|
||||
cls, from_version: Version, to_version: Version
|
||||
) -> Callable[[Callable[[AppConfigDict], AppConfigDict]], Callable[[AppConfigDict], AppConfigDict]]:
|
||||
"""Define a decorator which registers the migration between two versions."""
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def migrate(cls, config: AppConfigDict) -> AppConfigDict:
|
||||
"""
|
||||
Use the registered migration steps to bring config up to latest version.
|
||||
|
||||
:param config: The original configuration.
|
||||
:return: The new configuration, lifted up to the latest version.
|
||||
|
||||
As a side effect, the new configuration will be written to disk.
|
||||
"""
|
||||
|
||||
|
||||
class MigrationEntry(BaseModel):
|
||||
"""Defines an individual migration."""
|
||||
|
||||
@ -54,7 +30,7 @@ class MigrationEntry(BaseModel):
|
||||
return v
|
||||
|
||||
|
||||
class ConfigMigrator(ConfigMigratorBase):
|
||||
class ConfigMigrator:
|
||||
"""This class allows migrators to register their input and output versions."""
|
||||
|
||||
_migrations: List[MigrationEntry] = []
|
||||
|
Loading…
Reference in New Issue
Block a user