fix(config): edge cases in models.yaml migration

When running the configurator, the `legacy_models_conf_path` was stripped when saving the config file. Then the migration logic didn't fire correctly, and the custom models.yaml paths weren't migrated into the db.

- Rework the logic to migrate this path by adding it to the config object as a normal field that is not excluded from serialization.
- Rearrange the models.yaml migration logic to remove the legacy path after migrating, then write the config file. This way, the legacy path doesn't stick around.
- Move the schema version into the config object.
- Back up the config file before attempting migration.
- Add tests to cover this edge case
This commit is contained in:
psychedelicious
2024-03-15 23:21:21 +11:00
parent 1ed1c1fb24
commit e76cc71e81
5 changed files with 92 additions and 55 deletions

View File

@ -34,6 +34,7 @@ from transformers import AutoFeatureExtractor
import invokeai.configs as model_configs
from invokeai.app.services.config import InvokeAIAppConfig
from invokeai.app.services.config.config_default import get_config
from invokeai.backend.install.install_helper import InstallHelper, InstallSelections
from invokeai.backend.model_manager import ModelType
from invokeai.backend.util import choose_precision, choose_torch_device
@ -63,8 +64,7 @@ def get_literal_fields(field: str) -> Tuple[Any]:
# --------------------------globals-----------------------
# Start from a fresh config object - we will read the user's config from file later, and update it with their choices
config = InvokeAIAppConfig()
config = get_config()
PRECISION_CHOICES = get_literal_fields("precision")
DEVICE_CHOICES = get_literal_fields("device")