mirror of https://github.com/vladmandic/automatic
fix pydantic
parent
47543663f9
commit
bd39638df1
|
|
@ -1,8 +1,8 @@
|
|||
# Change Log for SD.Next
|
||||
|
||||
## Update for 2026-02-18
|
||||
## Update for 2026-02-20
|
||||
|
||||
### Highlights for 2026-02-18
|
||||
### Highlights for 2026-02-20
|
||||
|
||||
TBD
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@ import inspect
|
|||
from typing import Any, Optional, Union
|
||||
from collections.abc import Callable
|
||||
from pydantic import BaseModel, Field, create_model
|
||||
from pydantic import VERSION
|
||||
PYDANTIC_V2 = VERSION.startswith("2.")
|
||||
|
||||
try:
|
||||
from pydantic import ConfigDict
|
||||
PYDANTIC_V2 = True
|
||||
except ImportError:
|
||||
ConfigDict = None
|
||||
PYDANTIC_V2 = False
|
||||
|
||||
try:
|
||||
from pydantic import BaseConfig
|
||||
except ImportError:
|
||||
BaseConfig = object
|
||||
from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img
|
||||
import modules.shared as shared
|
||||
|
||||
|
|
@ -28,7 +34,7 @@ class ModelDef(BaseModel):
|
|||
field_exclude: bool = False
|
||||
|
||||
|
||||
class DummyConfig:
|
||||
class DummyConfig(BaseConfig):
|
||||
dummy_value = None
|
||||
|
||||
|
||||
|
|
@ -36,7 +42,7 @@ if not hasattr(BaseModel, "__config__"):
|
|||
BaseModel.__config__ = DummyConfig
|
||||
|
||||
|
||||
class PydanticConfig:
|
||||
class PydanticConfig(BaseConfig):
|
||||
arbitrary_types_allowed = True
|
||||
orm_mode = True
|
||||
allow_population_by_field_name = True
|
||||
|
|
@ -492,15 +498,19 @@ def create_model_from_signature(func: Callable, model_name: str, base_model: typ
|
|||
|
||||
if PYDANTIC_V2:
|
||||
config = ConfigDict(arbitrary_types_allowed=True, from_attributes=True, populate_by_name=True, extra='allow' if varkw else 'ignore')
|
||||
create_model_args = {'__base__': base_model, '__config__': config}
|
||||
else:
|
||||
class CustomConfig(PydanticConfig):
|
||||
extra = 'allow' if varkw else 'ignore'
|
||||
config = CustomConfig
|
||||
if base_model == BaseModel:
|
||||
create_model_args = {'__config__': config}
|
||||
else:
|
||||
create_model_args = {'__base__': base_model}
|
||||
|
||||
model = create_model(
|
||||
model_name,
|
||||
__base__=base_model,
|
||||
__config__=config,
|
||||
**create_model_args,
|
||||
**model_fields,
|
||||
**keyword_only_params,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ pytorch_lightning==2.6.0
|
|||
urllib3==1.26.19
|
||||
Pillow==10.4.0
|
||||
timm==1.0.24
|
||||
pyparsing==3.2.3
|
||||
typing-extensions==4.14.1
|
||||
pyparsing==3.3.2
|
||||
typing-extensions==4.15.0
|
||||
sentencepiece==0.2.1
|
||||
|
||||
# lint
|
||||
|
|
|
|||
Loading…
Reference in New Issue