mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
perf: TypeAdapter instantiated once
This commit is contained in:
parent
f2777f5096
commit
1d2bd6b8f7
@ -172,11 +172,12 @@ 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, Union, get_type_hints
|
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypeVar, Union, get_type_hints
|
||||||
|
|
||||||
from omegaconf import DictConfig, OmegaConf
|
from omegaconf import DictConfig, OmegaConf
|
||||||
from pydantic import Field, TypeAdapter
|
from pydantic import Field, TypeAdapter as PyTypeAdapter
|
||||||
from pydantic.config import JsonDict
|
from pydantic.config import JsonDict
|
||||||
from pydantic_settings import SettingsConfigDict
|
from pydantic_settings import SettingsConfigDict
|
||||||
|
|
||||||
@ -187,6 +188,13 @@ 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."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user