Files
wehub-resource-sync cddb07a176
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:06 +08:00

60 lines
2.1 KiB
Python

from logging import Logger
from typing import TYPE_CHECKING
from invokeai.app.services.model_records.model_records_base import ModelRecordChanges
from invokeai.backend.model_manager.configs.external_api import ExternalApiModelConfig
from invokeai.backend.model_manager.starter_models import STARTER_MODELS
from invokeai.backend.model_manager.taxonomy import BaseModelType, ModelType
if TYPE_CHECKING:
from invokeai.app.services.model_manager.model_manager_base import ModelManagerServiceBase
def sync_configured_external_starter_models(
configured_provider_ids: set[str],
model_manager: "ModelManagerServiceBase",
logger: Logger,
) -> list[str]:
"""Queue missing external starter models for configured providers."""
if not configured_provider_ids:
return []
installed_sources = {
model.source
for model in model_manager.store.search_by_attr(
base_model=BaseModelType.External,
model_type=ModelType.ExternalImageGenerator,
)
if isinstance(model, ExternalApiModelConfig) and model.source
}
queued_sources: list[str] = []
for starter_model in STARTER_MODELS:
if not starter_model.source.startswith("external://"):
continue
provider_id = starter_model.source.removeprefix("external://").split("/", 1)[0]
if provider_id not in configured_provider_ids:
continue
if starter_model.source in installed_sources:
continue
model_manager.install.heuristic_import(
starter_model.source,
config=ModelRecordChanges(
name=starter_model.name,
base=starter_model.base,
type=starter_model.type,
description=starter_model.description,
format=starter_model.format,
capabilities=starter_model.capabilities,
default_settings=starter_model.default_settings,
),
)
queued_sources.append(starter_model.source)
logger.info("Queued external starter model sync for %s", starter_model.source)
return queued_sources