2
2
import sqlite3
3
3
from logging import Logger
4
4
from pathlib import Path
5
- from typing import NamedTuple
5
+ from typing import Any , NamedTuple
6
6
7
7
from pydantic import ValidationError
8
8
@@ -29,8 +29,9 @@ def __call__(self, cursor: sqlite3.Cursor) -> None:
29
29
30
30
for model_id , config_json in rows :
31
31
try :
32
+ migrated_config_dict = self ._migrate_config (config_json )
32
33
# Get the model config as a pydantic object
33
- config = AnyModelConfigValidator .validate_json ( config_json )
34
+ config = AnyModelConfigValidator .validate_python ( migrated_config_dict )
34
35
except ValidationError :
35
36
# This could happen if the config schema changed in a way that makes old configs invalid. Unlikely
36
37
# for users, more likely for devs testing out migration paths.
@@ -76,6 +77,26 @@ def __call__(self, cursor: sqlite3.Cursor) -> None:
76
77
77
78
self ._prune_empty_directories ()
78
79
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
+
79
100
def _normalize_model_storage (self , key : str , path_value : str ) -> NormalizeResult :
80
101
models_dir = self ._models_dir
81
102
stored_path = Path (path_value )
0 commit comments