mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
perf: remove TypeAdapter
This commit is contained in:
parent
1d2bd6b8f7
commit
dcfc883ab3
@ -172,12 +172,11 @@ two configs are kept in separate sections of the config file:
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypeVar, Union, get_type_hints
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
from omegaconf import DictConfig, OmegaConf
|
from omegaconf import DictConfig, OmegaConf
|
||||||
from pydantic import Field, TypeAdapter as PyTypeAdapter
|
from pydantic import Field
|
||||||
from pydantic.config import JsonDict
|
from pydantic.config import JsonDict
|
||||||
from pydantic_settings import SettingsConfigDict
|
from pydantic_settings import SettingsConfigDict
|
||||||
|
|
||||||
@ -188,13 +187,6 @@ DB_FILE = Path("invokeai.db")
|
|||||||
LEGACY_INIT_FILE = Path("invokeai.init")
|
LEGACY_INIT_FILE = Path("invokeai.init")
|
||||||
DEFAULT_MAX_VRAM = 0.5
|
DEFAULT_MAX_VRAM = 0.5
|
||||||
|
|
||||||
_T = TypeVar("_T")
|
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
|
||||||
def TypeAdapter(type_: type[_T]) -> PyTypeAdapter:
|
|
||||||
return PyTypeAdapter(type_)
|
|
||||||
|
|
||||||
|
|
||||||
class Categories(object):
|
class Categories(object):
|
||||||
"""Category headers for configuration variable groups."""
|
"""Category headers for configuration variable groups."""
|
||||||
@ -344,13 +336,8 @@ class InvokeAIAppConfig(InvokeAISettings):
|
|||||||
super().parse_args(argv)
|
super().parse_args(argv)
|
||||||
|
|
||||||
if self.singleton_init and not clobber:
|
if self.singleton_init and not clobber:
|
||||||
hints = get_type_hints(self.__class__)
|
for k, v in self.singleton_init.items():
|
||||||
for k in self.singleton_init:
|
setattr(self, k, v)
|
||||||
setattr(
|
|
||||||
self,
|
|
||||||
k,
|
|
||||||
TypeAdapter(hints[k]).validate_python(self.singleton_init[k]),
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_config(cls, **kwargs: Any) -> InvokeAIAppConfig:
|
def get_config(cls, **kwargs: Any) -> InvokeAIAppConfig:
|
||||||
|
Loading…
Reference in New Issue
Block a user