mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat: normalize and validate checkpoint entries before enrichment
Add _normalize_checkpoint_entry method to handle legacy checkpoint data formats (strings, tuples) by converting them to dictionaries. This prevents errors during enrichment when checkpoint data is not in the expected dictionary format. Invalid checkpoint entries are now removed instead of causing processing failures. - Update get_paginated_data and get_recipe_by_id methods to use normalization - Add test cases for legacy string and tuple checkpoint formats - Ensure backward compatibility with existing checkpoint handling
This commit is contained in:
@@ -949,7 +949,11 @@ class RecipeScanner:
|
||||
if 'loras' in item:
|
||||
item['loras'] = [self._enrich_lora_entry(dict(lora)) for lora in item['loras']]
|
||||
if item.get('checkpoint'):
|
||||
item['checkpoint'] = self._enrich_checkpoint_entry(dict(item['checkpoint']))
|
||||
checkpoint_entry = self._normalize_checkpoint_entry(item['checkpoint'])
|
||||
if checkpoint_entry:
|
||||
item['checkpoint'] = self._enrich_checkpoint_entry(checkpoint_entry)
|
||||
else:
|
||||
item.pop('checkpoint', None)
|
||||
|
||||
result = {
|
||||
'items': paginated_items,
|
||||
@@ -998,7 +1002,11 @@ class RecipeScanner:
|
||||
if 'loras' in formatted_recipe:
|
||||
formatted_recipe['loras'] = [self._enrich_lora_entry(dict(lora)) for lora in formatted_recipe['loras']]
|
||||
if formatted_recipe.get('checkpoint'):
|
||||
formatted_recipe['checkpoint'] = self._enrich_checkpoint_entry(dict(formatted_recipe['checkpoint']))
|
||||
checkpoint_entry = self._normalize_checkpoint_entry(formatted_recipe['checkpoint'])
|
||||
if checkpoint_entry:
|
||||
formatted_recipe['checkpoint'] = self._enrich_checkpoint_entry(checkpoint_entry)
|
||||
else:
|
||||
formatted_recipe.pop('checkpoint', None)
|
||||
|
||||
return formatted_recipe
|
||||
|
||||
|
||||
Reference in New Issue
Block a user