From 52a8ad1c185145af5d2a3a5c4bc1da17080e36c3 Mon Sep 17 00:00:00 2001
From: Kevin Turner <566360-keturn@users.noreply.gitlab.com>
Date: Sat, 5 Apr 2025 15:05:00 -0700
Subject: [PATCH] chore: rename model.size to model.file_size
to disambiguate from RAM size or pixel size
---
invokeai/app/api/routers/model_manager.py | 2 +-
.../model_records/model_records_base.py | 2 +-
.../migrations/migration_19.py | 6 +-
invokeai/backend/model_manager/config.py | 4 +-
.../backend/model_manager/legacy_probe.py | 2 +-
invokeai/frontend/web/public/locales/en.json | 2 +-
.../ModelManagerPanel/ModelListItem.tsx | 2 +-
.../subpanels/ModelPanel/ModelView.tsx | 4 +-
.../nodes/util/graph/generation/Graph.test.ts | 2 +-
.../frontend/web/src/services/api/schema.ts | 108 +++++++++---------
.../model_records/test_model_records_sql.py | 26 ++---
.../model_manager/model_manager_fixtures.py | 10 +-
12 files changed, 85 insertions(+), 85 deletions(-)
diff --git a/invokeai/app/api/routers/model_manager.py b/invokeai/app/api/routers/model_manager.py
index 8612ae5f73..9e03dbfc12 100644
--- a/invokeai/app/api/routers/model_manager.py
+++ b/invokeai/app/api/routers/model_manager.py
@@ -85,7 +85,7 @@ example_model_config = {
"config_path": "string",
"key": "string",
"hash": "string",
- "size": 1,
+ "file_size": 1,
"description": "string",
"source": "string",
"converted_at": 0,
diff --git a/invokeai/app/services/model_records/model_records_base.py b/invokeai/app/services/model_records/model_records_base.py
index 1afeb6c138..2cd29f5289 100644
--- a/invokeai/app/services/model_records/model_records_base.py
+++ b/invokeai/app/services/model_records/model_records_base.py
@@ -80,7 +80,7 @@ class ModelRecordChanges(BaseModelExcludeNull):
type: Optional[ModelType] = Field(description="Type of model", default=None)
key: Optional[str] = Field(description="Database ID for this model", default=None)
hash: Optional[str] = Field(description="hash of model file", default=None)
- size: Optional[int] = Field(description="Size of model file", default=None)
+ file_size: Optional[int] = Field(description="Size of model file", default=None)
format: Optional[str] = Field(description="format of model file", default=None)
trigger_phrases: Optional[set[str]] = Field(description="Set of trigger phrases for this model", default=None)
default_settings: Optional[MainModelDefaultSettings | ControlAdapterDefaultSettings] = Field(
diff --git a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_19.py b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_19.py
index dd40d8e4da..363cd2e8d8 100644
--- a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_19.py
+++ b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_19.py
@@ -15,8 +15,8 @@ class Migration19Callback:
def _add_size_column(self, cursor: sqlite3.Cursor) -> None:
cursor.execute(
- "ALTER TABLE models ADD COLUMN size INTEGER "
- "GENERATED ALWAYS as (json_extract(config, '$.size')) VIRTUAL NOT NULL"
+ "ALTER TABLE models ADD COLUMN file_size INTEGER "
+ "GENERATED ALWAYS as (json_extract(config, '$.file_size')) VIRTUAL NOT NULL"
)
def _populate_size(self, cursor: sqlite3.Cursor) -> None:
@@ -25,7 +25,7 @@ class Migration19Callback:
for model_id, model_path in all_models:
mod = ModelOnDisk(self.models_path / model_path)
cursor.execute(
- "UPDATE models SET config = json_set(config, '$.size', ?) WHERE id = ?", (mod.size(), model_id)
+ "UPDATE models SET config = json_set(config, '$.file_size', ?) WHERE id = ?", (mod.size(), model_id)
)
diff --git a/invokeai/backend/model_manager/config.py b/invokeai/backend/model_manager/config.py
index 3204e7ef00..4b753f64a7 100644
--- a/invokeai/backend/model_manager/config.py
+++ b/invokeai/backend/model_manager/config.py
@@ -128,7 +128,7 @@ class ModelConfigBase(ABC, BaseModel):
path: str = Field(
description="Path to the model on the filesystem. Relative paths are relative to the Invoke root directory."
)
- size: int = Field(description="The size of the model in bytes.")
+ file_size: int = Field(description="The size of the model in bytes.")
name: str = Field(description="Name of the model.")
type: ModelType = Field(description="Model type")
format: ModelFormat = Field(description="Model format")
@@ -242,7 +242,7 @@ class ModelConfigBase(ABC, BaseModel):
fields["key"] = fields.get("key") or uuid_string()
fields["description"] = fields.get("description") or f"{base.value} {type.value} model {name}"
fields["repo_variant"] = fields.get("repo_variant") or mod.repo_variant()
- fields["size"] = fields.get("size") or mod.size()
+ fields["file_size"] = fields.get("file_size") or mod.size()
return cls(**fields)
diff --git a/invokeai/backend/model_manager/legacy_probe.py b/invokeai/backend/model_manager/legacy_probe.py
index 65eae09f0d..4dc0822076 100644
--- a/invokeai/backend/model_manager/legacy_probe.py
+++ b/invokeai/backend/model_manager/legacy_probe.py
@@ -208,7 +208,7 @@ class ModelProbe(object):
)
fields["format"] = ModelFormat(fields.get("format")) if "format" in fields else probe.get_format()
fields["hash"] = fields.get("hash") or ModelHash(algorithm=hash_algo).hash(model_path)
- fields["size"] = fields.get("size") or ModelOnDisk(model_path).size()
+ fields["file_size"] = fields.get("file_size") or ModelOnDisk(model_path).size()
fields["default_settings"] = fields.get("default_settings")
diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json
index e1cfdd7dd9..4d05be4dd4 100644
--- a/invokeai/frontend/web/public/locales/en.json
+++ b/invokeai/frontend/web/public/locales/en.json
@@ -767,6 +767,7 @@
"deleteMsg2": "This WILL delete the model from disk if it is in the InvokeAI root folder. If you are using a custom location, then the model WILL NOT be deleted from disk.",
"description": "Description",
"edit": "Edit",
+ "fileSize": "File Size",
"fluxRedux": "FLUX Redux",
"height": "Height",
"huggingFace": "HuggingFace",
@@ -841,7 +842,6 @@
"selectModel": "Select Model",
"settings": "Settings",
"simpleModelPlaceholder": "URL or path to a local file or diffusers folder",
- "size": "Size",
"source": "Source",
"sigLip": "SigLIP",
"spandrelImageToImage": "Image to Image (Spandrel)",
diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx
index 0573a7179a..c8cb50601d 100644
--- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx
+++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx
@@ -109,7 +109,7 @@ const ModelListItem = ({ model }: ModelListItemProps) => {
- {(model.size / 1024 ** 3).toLocaleString(undefined, {
+ {(model.file_size / 1024 ** 3).toLocaleString(undefined, {
maximumFractionDigits: 2,
style: 'unit',
unit: 'gigabyte',
diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelView.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelView.tsx
index e976d09454..008529dcc0 100644
--- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelView.tsx
+++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelView.tsx
@@ -51,8 +51,8 @@ export const ModelView = memo(({ modelConfig }: Props) => {
{
key: 'b00ee8df-523d-40d2-9578-597283b07cb2',
hash: 'random:9adf270422f525715297afa1649c4ff007a55f09937f57ca628278305624d194',
path: 'sdxl/main/stable-diffusion-xl-1.0-inpainting-0.1',
- size: 6123456789,
+ file_size: 6123456789,
name: 'stable-diffusion-xl-1.0-inpainting-0.1',
base: 'sdxl',
description: 'sdxl main model stable-diffusion-xl-1.0-inpainting-0.1',
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index 070b09de2d..44984a1db3 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -2914,10 +2914,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -2996,10 +2996,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -3154,10 +3154,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -4316,10 +4316,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -4409,10 +4409,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -4490,10 +4490,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -4577,10 +4577,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -7772,10 +7772,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -8552,10 +8552,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -8745,10 +8745,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -12817,10 +12817,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -12987,10 +12987,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -13153,10 +13153,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -13424,10 +13424,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -13527,10 +13527,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -13631,10 +13631,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -13719,10 +13719,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -15848,10 +15848,10 @@ export type components = {
*/
hash?: string | null;
/**
- * Size
+ * File Size
* @description Size of model file
*/
- size?: number | null;
+ file_size?: number | null;
/**
* Format
* @description format of model file
@@ -18580,10 +18580,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -18724,10 +18724,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -19446,10 +19446,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -19669,10 +19669,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -19740,10 +19740,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -19848,10 +19848,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -19922,10 +19922,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -20446,10 +20446,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
@@ -20531,10 +20531,10 @@ export type components = {
*/
path: string;
/**
- * Size
+ * File Size
* @description The size of the model in bytes.
*/
- size: number;
+ file_size: number;
/**
* Name
* @description Name of the model.
diff --git a/tests/app/services/model_records/test_model_records_sql.py b/tests/app/services/model_records/test_model_records_sql.py
index 28dc74ebeb..c8b5698dd8 100644
--- a/tests/app/services/model_records/test_model_records_sql.py
+++ b/tests/app/services/model_records/test_model_records_sql.py
@@ -45,7 +45,7 @@ def example_ti_config(key: Optional[str] = None) -> TextualInversionFileConfig:
source="test/source/",
source_type=ModelSourceType.Path,
path="/tmp/pokemon.bin",
- size=1024,
+ file_size=1024,
name="old name",
base=BaseModelType.StableDiffusion1,
type=ModelType.TextualInversion,
@@ -129,7 +129,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG1HASH",
- size=1001,
+ file_size=1001,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -140,7 +140,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG2HASH",
- size=1002,
+ file_size=1002,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -151,7 +151,7 @@ def test_filter(store: ModelRecordServiceBase):
base=BaseModelType("sd-2"),
type=ModelType.VAE,
hash="CONFIG3HASH",
- size=1003,
+ file_size=1003,
source="test/source",
source_type=ModelSourceType.Path,
)
@@ -182,7 +182,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
- size=1004,
+ file_size=1004,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -192,7 +192,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
- size=1005,
+ file_size=1005,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -202,7 +202,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.VAE,
name="nonuniquename",
hash="CONFIG1HASH",
- size=1006,
+ file_size=1006,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -212,7 +212,7 @@ def test_unique(store: ModelRecordServiceBase):
type=ModelType.Main,
name="nonuniquename",
hash="CONFIG1HASH",
- size=1007,
+ file_size=1007,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -235,7 +235,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG1HASH",
- size=1008,
+ file_size=1008,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -245,7 +245,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.Main,
hash="CONFIG2HASH",
- size=1009,
+ file_size=1009,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -255,7 +255,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType("sd-2"),
type=ModelType.Main,
hash="CONFIG3HASH",
- size=1010,
+ file_size=1010,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -265,7 +265,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType("sdxl"),
type=ModelType.Main,
hash="CONFIG3HASH",
- size=1011,
+ file_size=1011,
source="test/source/",
source_type=ModelSourceType.Path,
)
@@ -275,7 +275,7 @@ def test_filter_2(store: ModelRecordServiceBase):
base=BaseModelType.StableDiffusion1,
type=ModelType.VAE,
hash="CONFIG3HASH",
- size=1012,
+ file_size=1012,
source="test/source/",
source_type=ModelSourceType.Path,
)
diff --git a/tests/backend/model_manager/model_manager_fixtures.py b/tests/backend/model_manager/model_manager_fixtures.py
index 161908d0dd..a1933d7eff 100644
--- a/tests/backend/model_manager/model_manager_fixtures.py
+++ b/tests/backend/model_manager/model_manager_fixtures.py
@@ -140,7 +140,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusion2,
type=ModelType.VAE,
hash="111222333444",
- size=4096,
+ file_size=4096,
source="stabilityai/sdxl-vae",
source_type=ModelSourceType.HFRepoID,
)
@@ -154,7 +154,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
config_path="/tmp/foo.yaml",
variant=ModelVariantType.Normal,
hash="111222333444",
- size=8192,
+ file_size=8192,
source="https://civitai.com/models/206883/split",
source_type=ModelSourceType.Url,
)
@@ -166,7 +166,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusionXL,
type=ModelType.Main,
hash="111222333444",
- size=8193,
+ file_size=8193,
source="author3/model3",
description="This is test 3",
source_type=ModelSourceType.HFRepoID,
@@ -179,7 +179,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusionXL,
type=ModelType.LoRA,
hash="111222333444",
- size=5000,
+ file_size=5000,
source="author4/model4",
source_type=ModelSourceType.HFRepoID,
)
@@ -191,7 +191,7 @@ def mm2_record_store(mm2_app_config: InvokeAIAppConfig) -> ModelRecordServiceBas
base=BaseModelType.StableDiffusion1,
type=ModelType.LoRA,
hash="111222333444",
- size=5001,
+ file_size=5001,
source="author4/model5",
source_type=ModelSourceType.HFRepoID,
)