mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 06:02:11 -03:00
Enhance node processing and error handling in workflow mappers
- Improved reference handling in NodeMapper to support integer node IDs and added error logging for reference processing failures. - Updated LoraLoaderMapper and LoraStackerMapper to handle lora_stack as a dictionary, ensuring compatibility with new data formats. - Refactored trace_model_path utility to perform a depth-first search for LoRA nodes, improving the accuracy of model path tracing. - Cleaned up unused code in parser.py related to LoRA processing, streamlining the workflow parsing logic.
This commit is contained in:
45
test_parser.py
Normal file
45
test_parser.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import json
|
||||
import sys
|
||||
from py.workflow.parser import WorkflowParser
|
||||
from py.workflow.utils import trace_model_path
|
||||
|
||||
# Load workflow data
|
||||
with open('refs/prompt.json', 'r') as f:
|
||||
workflow_data = json.load(f)
|
||||
|
||||
# Parse workflow
|
||||
parser = WorkflowParser()
|
||||
try:
|
||||
# Find KSampler node
|
||||
ksampler_node = None
|
||||
for node_id, node in workflow_data.items():
|
||||
if node.get("class_type") == "KSampler":
|
||||
ksampler_node = node_id
|
||||
break
|
||||
|
||||
if not ksampler_node:
|
||||
print("KSampler node not found")
|
||||
sys.exit(1)
|
||||
|
||||
# Trace all Lora nodes
|
||||
print("Finding Lora nodes in the workflow...")
|
||||
lora_nodes = trace_model_path(workflow_data, ksampler_node)
|
||||
print(f"Found Lora nodes: {lora_nodes}")
|
||||
|
||||
# Print node details
|
||||
for node_id in lora_nodes:
|
||||
node = workflow_data[node_id]
|
||||
print(f"\nNode {node_id}: {node.get('class_type')}")
|
||||
for key, value in node.get("inputs", {}).items():
|
||||
print(f" - {key}: {value}")
|
||||
|
||||
# Parse the workflow
|
||||
result = parser.parse_workflow(workflow_data)
|
||||
print("\nParsing successful!")
|
||||
print(json.dumps(result, indent=2))
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
print(f"Error parsing workflow: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user