mirror of
https://github.com/invoke-ai/InvokeAI
synced 2025-07-26 05:17:55 +00:00
Make ruff happy
This commit is contained in:
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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.")
|
||||
|
||||
|
Reference in New Issue
Block a user