chore(backend): rename ModelInfo -> LoadedModelInfo

We have two different classes named `ModelInfo` which might need to be used by API consumers. We need to export both but have to deal with this naming collision.

The `ModelInfo` I've renamed here is the one that is returned when a model is loaded. It's the object least likely to be used by API consumers.
This commit is contained in:
psychedelicious
2024-02-11 09:27:57 +11:00
parent 2005411f7e
commit 083a4f3faa
9 changed files with 38 additions and 30 deletions

View File

@ -7,7 +7,7 @@ import torch
from invokeai.app.services.config.config_default import InvokeAIAppConfig
from invokeai.backend.install.model_install_backend import ModelInstall
from invokeai.backend.model_management.model_manager import ModelInfo
from invokeai.backend.model_management.model_manager import LoadedModelInfo
from invokeai.backend.model_management.models.base import BaseModelType, ModelNotFoundException, ModelType, SubModelType
@ -34,8 +34,8 @@ def install_and_load_model(
base_model: BaseModelType,
model_type: ModelType,
submodel_type: Optional[SubModelType] = None,
) -> ModelInfo:
"""Install a model if it is not already installed, then get the ModelInfo for that model.
) -> LoadedModelInfo:
"""Install a model if it is not already installed, then get the LoadedModelInfo for that model.
This is intended as a utility function for tests.
@ -49,9 +49,9 @@ def install_and_load_model(
submodel_type (Optional[SubModelType]): The submodel type, forwarded to ModelManager.get_model(...).
Returns:
ModelInfo
LoadedModelInfo
"""
# If the requested model is already installed, return its ModelInfo.
# If the requested model is already installed, return its LoadedModelInfo.
with contextlib.suppress(ModelNotFoundException):
return model_installer.mgr.get_model(model_name, base_model, model_type, submodel_type)