mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Fix calculate_recipe_fingerprint to handle non-string hash and invalid strength values
- Handle non-string hash values by converting to string before lower() - Add try-except for strength conversion to handle invalid values like empty strings - Fixes hypothesis test failures when random data generates unexpected types
This commit is contained in:
@@ -189,15 +189,23 @@ def calculate_recipe_fingerprint(loras):
|
|||||||
if lora.get("exclude", False):
|
if lora.get("exclude", False):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
hash_value = lora.get("hash", "").lower()
|
hash_value = lora.get("hash", "")
|
||||||
|
if isinstance(hash_value, str):
|
||||||
|
hash_value = hash_value.lower()
|
||||||
|
else:
|
||||||
|
hash_value = str(hash_value).lower() if hash_value else ""
|
||||||
if not hash_value and lora.get("modelVersionId"):
|
if not hash_value and lora.get("modelVersionId"):
|
||||||
hash_value = str(lora.get("modelVersionId"))
|
hash_value = str(lora.get("modelVersionId"))
|
||||||
|
|
||||||
if not hash_value:
|
if not hash_value:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Normalize strength to 2 decimal places (check both strength and weight fields)
|
# Normalize strength to 2 decimal places (check both strength and weight fields)
|
||||||
strength = round(float(lora.get("strength", lora.get("weight", 1.0))), 2)
|
strength_val = lora.get("strength", lora.get("weight", 1.0))
|
||||||
|
try:
|
||||||
|
strength = round(float(strength_val), 2)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
strength = 1.0
|
||||||
|
|
||||||
valid_loras.append((hash_value, strength))
|
valid_loras.append((hash_value, strength))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user