fix: image model ranking crashes when system is not a dict (#1900)
This commit is contained in:
@@ -280,6 +280,8 @@ def rank_image_models(system, search=None, sort="fit"):
|
||||
|
||||
Returns list of models with fit info (vram needed, fits, recommended quant).
|
||||
"""
|
||||
if not isinstance(system, dict):
|
||||
system = {}
|
||||
gpu_vram = system.get("gpu_vram_gb", 0) or 0
|
||||
has_gpu = system.get("has_gpu", False)
|
||||
results = []
|
||||
|
||||
9
tests/test_image_models_nondict_system.py
Normal file
9
tests/test_image_models_nondict_system.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from services.hwfit.image_models import rank_image_models, IMAGE_MODEL_REGISTRY
|
||||
|
||||
|
||||
def test_rank_image_models_handles_non_dict_system():
|
||||
# `system` is the detected-hardware dict; if detection failed and returned
|
||||
# None (or a non-dict), system.get(...) raised AttributeError. Treat a
|
||||
# non-dict system as "unknown hardware" (no GPU) rather than crashing.
|
||||
assert len(rank_image_models(None)) == len(IMAGE_MODEL_REGISTRY)
|
||||
assert len(rank_image_models(123)) == len(IMAGE_MODEL_REGISTRY)
|
||||
Reference in New Issue
Block a user