Make ruff happy

This commit is contained in:
Billy
2025-05-16 16:10:36 +10:00
committed by psychedelicious
parent a17e771eba
commit af41dc83f7
4 changed files with 4 additions and 10 deletions

View File

@ -38,9 +38,9 @@ from invokeai.backend.model_manager.config import (
AnyModelConfig,
CheckpointConfigBase,
InvalidModelConfigException,
ModelConfigBase,
)
from invokeai.backend.model_manager.legacy_probe import ModelProbe
from invokeai.backend.model_manager.config import ModelConfigBase
from invokeai.backend.model_manager.metadata import (
AnyModelRepoMetadata,
HuggingFaceMetadataFetch,

View File

@ -164,11 +164,7 @@ class ModelConfigBase(ABC, BaseModel):
return concrete
@staticmethod
def classify(
mod: str | Path | ModelOnDisk,
hash_algo: HASHING_ALGORITHMS = "blake3_single",
**overrides
):
def classify(mod: str | Path | ModelOnDisk, hash_algo: HASHING_ALGORITHMS = "blake3_single", **overrides):
"""
Returns the best matching ModelConfig instance from a model's file/folder path.
Raises InvalidModelConfigException if no valid configuration is found.

View File

@ -32,6 +32,7 @@ def classify_with_fallback(path: Path, hash_algo: HASHING_ALGORITHMS):
except InvalidModelConfigException:
return ModelConfigBase.classify(path, hash_algo)
for path in args.model_path:
try:
config = classify_with_fallback(path, args.hash_algo)

View File

@ -261,13 +261,10 @@ def test_any_model_config_includes_all_config_classes():
def test_config_uniquely_matches_model(datadir: Path):
model_paths = ModelSearch().search(datadir / "stripped_models")
for path in model_paths:
mod = StrippedModelOnDisk(path)
matches = { cls for cls in ModelConfigBase.USING_CLASSIFY_API if cls.matches(mod) }
matches = {cls for cls in ModelConfigBase.USING_CLASSIFY_API if cls.matches(mod)}
assert len(matches) <= 1, f"Model at path {path} matches multiple config classes: {matches}"
if not matches:
logger.warning(f"Model at path {path} does not match any config classes using classify API.")