mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(config): handle relative paths to v3 models.yamls
This commit is contained in:
parent
b02f2da71d
commit
f5337c7ce2
@ -127,6 +127,7 @@ class InvokeAIAppConfig(BaseSettings):
|
|||||||
|
|
||||||
# INTERNAL
|
# INTERNAL
|
||||||
schema_version: int = Field(default=CONFIG_SCHEMA_VERSION, description="Schema version of the config file. This is not a user-configurable setting.")
|
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.")
|
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
|
# WEB
|
||||||
@ -231,11 +232,8 @@ class InvokeAIAppConfig(BaseSettings):
|
|||||||
dest_path: Path to write the config to.
|
dest_path: Path to write the config to.
|
||||||
"""
|
"""
|
||||||
with open(dest_path, "w") as file:
|
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"})
|
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
|
# User settings
|
||||||
config_dict = self.model_dump(
|
config_dict = self.model_dump(
|
||||||
|
@ -304,6 +304,10 @@ class ModelInstallService(ModelInstallServiceBase):
|
|||||||
self._app_config.legacy_models_yaml_path or self._app_config.root_path / "configs" / "models.yaml"
|
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():
|
if legacy_models_yaml_path.exists():
|
||||||
legacy_models_yaml = yaml.safe_load(legacy_models_yaml_path.read_text())
|
legacy_models_yaml = yaml.safe_load(legacy_models_yaml_path.read_text())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user