From f96b7f2e1147219903f953b99a5ae284ce5c5542 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:21:37 +1100 Subject: [PATCH] fix(nodes): make fields on `ModelConfigBase` required The setup of `ModelConfigBase` means autogenerated types have critical fields flagged as nullable (like `key` and `base`). Need to manually flag them as required. --- invokeai/backend/model_manager/config.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/invokeai/backend/model_manager/config.py b/invokeai/backend/model_manager/config.py index bc4848b0a5..fb0593a651 100644 --- a/invokeai/backend/model_manager/config.py +++ b/invokeai/backend/model_manager/config.py @@ -138,9 +138,16 @@ class ModelConfigBase(BaseModel): source: Optional[str] = Field(description="model original source (path, URL or repo_id)", default=None) last_modified: Optional[float] = Field(description="timestamp for modification time", default_factory=time.time) + @staticmethod + def json_schema_extra(schema: dict[str, Any], model_class: Type[BaseModel]) -> None: + schema["required"].extend( + ["key", "base", "type", "format", "original_hash", "current_hash", "source", "last_modified"] + ) + model_config = ConfigDict( use_enum_values=False, validate_assignment=True, + json_schema_extra=json_schema_extra, ) def update(self, attributes: Dict[str, Any]) -> None: