mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Skip list logic if the list only contains primitives
This commit is contained in:
parent
97afa6e2a6
commit
46fd3465ce
@ -18,7 +18,7 @@ from pathlib import Path
|
||||
from pydantic import BaseModel
|
||||
from typing import Any, ClassVar, Dict, List, Literal, Optional, Union, get_args, get_origin, get_type_hints
|
||||
|
||||
from omegaconf import DictConfig, ListConfig, OmegaConf
|
||||
from omegaconf import DictConfig, ListConfig, OmegaConf, DictKeyType
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
from invokeai.app.services.config.config_common import PagingArgumentParser, int_or_float_or_str
|
||||
@ -68,13 +68,17 @@ class InvokeAISettings(BaseSettings):
|
||||
field_dict[type][category][name] = dump
|
||||
continue
|
||||
if isinstance(value, list):
|
||||
val_list: List[Dict[str, Any]] = []
|
||||
for list_val in value:
|
||||
if isinstance(list_val, BaseModel):
|
||||
dump = list_val.model_dump(exclude_defaults=True, exclude_unset=True, exclude_none=True)
|
||||
val_list.append(dump)
|
||||
field_dict[type][category][name] = val_list
|
||||
continue
|
||||
if not value or len(value) == 0:
|
||||
continue
|
||||
primitive = isinstance(value[0], get_args(DictKeyType))
|
||||
if not primitive:
|
||||
val_list: List[Dict[str, Any]] = []
|
||||
for list_val in value:
|
||||
if isinstance(list_val, BaseModel):
|
||||
dump = list_val.model_dump(exclude_defaults=True, exclude_unset=True, exclude_none=True)
|
||||
val_list.append(dump)
|
||||
field_dict[type][category][name] = val_list
|
||||
continue
|
||||
# keep paths as strings to make it easier to read
|
||||
field_dict[type][category][name] = str(value) if isinstance(value, Path) else value
|
||||
conf = OmegaConf.create(field_dict)
|
||||
|
Loading…
Reference in New Issue
Block a user