Skip to content

Commit d21707a

Browse files
docs(mm): add reminder for self for field migrations
1 parent 7c70701 commit d21707a

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

invokeai/app/services/shared/sqlite_migrator/migrations/migration_22.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sqlite3
33
from logging import Logger
44
from pathlib import Path
5-
from typing import NamedTuple
5+
from typing import Any, NamedTuple
66

77
from pydantic import ValidationError
88

@@ -29,8 +29,9 @@ def __call__(self, cursor: sqlite3.Cursor) -> None:
2929

3030
for model_id, config_json in rows:
3131
try:
32+
migrated_config_dict = self._migrate_config(config_json)
3233
# Get the model config as a pydantic object
33-
config = AnyModelConfigValidator.validate_json(config_json)
34+
config = AnyModelConfigValidator.validate_python(migrated_config_dict)
3435
except ValidationError:
3536
# This could happen if the config schema changed in a way that makes old configs invalid. Unlikely
3637
# for users, more likely for devs testing out migration paths.
@@ -76,6 +77,26 @@ def __call__(self, cursor: sqlite3.Cursor) -> None:
7677

7778
self._prune_empty_directories()
7879

80+
def _migrate_config(self, config_json: Any) -> str | None:
81+
config_dict = json.loads(config_json)
82+
83+
# TODO: migrate fields, review changes to ensure we hit all cases for v6.7.0 to v6.8.0 upgrade.
84+
85+
# Prior to v6.8.0, we used an awkward combination of `config_path` and `variant` to distinguish between FLUX
86+
# variants.
87+
#
88+
# `config_path` was set to one of:
89+
# - flux-dev
90+
# - flux-dev-fill
91+
# - flux-schnell
92+
#
93+
# `variant` was set to ModelVariantType.Inpaint for FLUX Fill models and ModelVariantType.Normal for all other FLUX
94+
# models.
95+
#
96+
# We now use the `variant` field to directly represent the FLUX variant type, and `config_path` is no longer used.
97+
98+
return config_dict
99+
79100
def _normalize_model_storage(self, key: str, path_value: str) -> NormalizeResult:
80101
models_dir = self._models_dir
81102
stored_path = Path(path_value)

invokeai/backend/model_manager/configs/main.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,6 @@ class Main_Checkpoint_FLUX_Config(Checkpoint_Config_Base, Main_Config_Base, Conf
264264
base: Literal[BaseModelType.Flux] = Field(default=BaseModelType.Flux)
265265

266266
variant: FluxVariantType = Field()
267-
# Prior to v6.8.0, we used an awkward combination of `config_path` and `variant` to distinguish between FLUX
268-
# variants.
269-
#
270-
# `config_path` was set to one of:
271-
# - flux-dev
272-
# - flux-dev-fill
273-
# - flux-schnell
274-
#
275-
# `variant` was set to ModelVariantType.Inpaint for FLUX Fill models and ModelVariantType.Normal for all other FLUX
276-
# models.
277-
#
278-
# We now use the `variant` field to directly represent the FLUX variant type, and `config_path` is no longer used.
279267

280268
@classmethod
281269
def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:

0 commit comments

Comments
 (0)