diff --git a/invokeai/app/services/config/config_default.py b/invokeai/app/services/config/config_default.py index 6e373151ae..6edd3283ca 100644 --- a/invokeai/app/services/config/config_default.py +++ b/invokeai/app/services/config/config_default.py @@ -127,6 +127,7 @@ class InvokeAIAppConfig(BaseSettings): # INTERNAL schema_version: int = Field(default=CONFIG_SCHEMA_VERSION, description="Schema version of the config file. This is not a user-configurable setting.") + # This is only used during v3 models.yaml migration legacy_models_yaml_path: Optional[Path] = Field(default=None, description="Path to the legacy models.yaml file. This is not a user-configurable setting.") # WEB @@ -231,11 +232,8 @@ class InvokeAIAppConfig(BaseSettings): dest_path: Path to write the config to. """ with open(dest_path, "w") as file: - # Meta fields should be written in a separate stanza + # Meta fields should be written in a separate stanza - skip legacy_models_yaml_path meta_dict = self.model_dump(mode="json", include={"schema_version"}) - # Only include the legacy_models_yaml_path if it's set - if self.legacy_models_yaml_path: - meta_dict.update(self.model_dump(mode="json", include={"legacy_models_yaml_path"})) # User settings config_dict = self.model_dump( diff --git a/invokeai/app/services/model_install/model_install_default.py b/invokeai/app/services/model_install/model_install_default.py index bd67535f79..bd41022037 100644 --- a/invokeai/app/services/model_install/model_install_default.py +++ b/invokeai/app/services/model_install/model_install_default.py @@ -304,6 +304,10 @@ class ModelInstallService(ModelInstallServiceBase): self._app_config.legacy_models_yaml_path or self._app_config.root_path / "configs" / "models.yaml" ) + # The old path may be relative to the root path + if not legacy_models_yaml_path.exists(): + legacy_models_yaml_path = Path(self._app_config.root_path, legacy_models_yaml_path) + if legacy_models_yaml_path.exists(): legacy_models_yaml = yaml.safe_load(legacy_models_yaml_path.read_text())