refactor: remove Lora Demo node

Remove the Lora Demo Node (LoraDemoNode) and all related imports and mappings
from the codebase.
This commit is contained in:
Will Miao
2026-01-14 22:44:53 +08:00
parent 40756b7dd3
commit 9ed5319ad2
2 changed files with 3 additions and 99 deletions

View File

@@ -9,7 +9,6 @@ try: # pragma: no cover - import fallback for pytest collection
from .py.nodes.wanvideo_lora_select import WanVideoLoraSelectLM
from .py.nodes.wanvideo_lora_select_from_text import WanVideoLoraSelectFromText
from .py.nodes.lora_pool import LoraPoolNode
from .py.nodes.lora_demo import LoraDemoNode
from .py.nodes.lora_randomizer import LoraRandomizerNode
from .py.metadata_collector import init as init_metadata_collector
except (
@@ -44,8 +43,9 @@ except (
"py.nodes.wanvideo_lora_select_from_text"
).WanVideoLoraSelectFromText
LoraPoolNode = importlib.import_module("py.nodes.lora_pool").LoraPoolNode
LoraDemoNode = importlib.import_module("py.nodes.lora_demo").LoraDemoNode
LoraRandomizerNode = importlib.import_module("py.nodes.lora_randomizer").LoraRandomizerNode
LoraRandomizerNode = importlib.import_module(
"py.nodes.lora_randomizer"
).LoraRandomizerNode
init_metadata_collector = importlib.import_module("py.metadata_collector").init
NODE_CLASS_MAPPINGS = {
@@ -59,7 +59,6 @@ NODE_CLASS_MAPPINGS = {
WanVideoLoraSelectLM.NAME: WanVideoLoraSelectLM,
WanVideoLoraSelectFromText.NAME: WanVideoLoraSelectFromText,
LoraPoolNode.NAME: LoraPoolNode,
LoraDemoNode.NAME: LoraDemoNode,
LoraRandomizerNode.NAME: LoraRandomizerNode,
}

View File

@@ -1,95 +0,0 @@
"""
Lora Demo Node - Demonstrates LORAS custom widget type usage.
This node accepts LORAS widget input and outputs a summary string.
"""
import logging
import random
logger = logging.getLogger(__name__)
class LoraDemoNode:
"""Demo node that uses LORAS custom widget type."""
NAME = "Lora Demo (LoraManager)"
CATEGORY = "Lora Manager/demo"
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"loras": ("LORAS", {}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("summary",)
FUNCTION = "process"
OUTPUT_NODE = False
async def process(self, loras):
"""
Process LoRAs input and return summary + UI data for widget.
Args:
loras: List of LoRA dictionaries with structure:
[{'name': str, 'strength': float, 'clipStrength': float, 'active': bool, ...}]
Returns:
Dictionary with 'result' (for workflow) and 'ui' (for frontend display)
"""
from ..services.service_registry import ServiceRegistry
# Get lora scanner to access available loras
scanner = await ServiceRegistry.get_lora_scanner()
# Get available loras from cache
available_loras = []
try:
cache_data = await scanner.get_cached_data(force_refresh=False)
if cache_data and hasattr(cache_data, "raw_data"):
available_loras = cache_data.raw_data
except Exception as e:
logger.warning(f"[LoraDemoNode] Failed to get lora cache: {e}")
# Randomly select 3-5 loras
num_to_select = random.randint(3, 5)
if len(available_loras) < num_to_select:
num_to_select = len(available_loras)
selected_loras = (
random.sample(available_loras, num_to_select) if num_to_select > 0 else []
)
# Generate random loras data for widget
widget_loras = []
for lora in selected_loras:
strength = round(random.uniform(0.1, 1.0), 2)
widget_loras.append(
{
"name": lora.get("file_name", "Unknown"),
"strength": strength,
"clipStrength": strength,
"active": True,
"expanded": False,
}
)
# Create summary string
active_names = [l["name"] for l in widget_loras]
summary = f"Randomized {len(active_names)} LoRAs: {', '.join(active_names)}"
logger.info(f"[LoraDemoNode] {summary}")
# Return format: result for workflow + ui for frontend
return {"result": (summary,), "ui": {"loras": widget_loras}}
# Node class mappings for ComfyUI
NODE_CLASS_MAPPINGS = {"LoraDemoNode": LoraDemoNode}
# Display name mappings
NODE_DISPLAY_NAME_MAPPINGS = {"LoraDemoNode": "LoRA Demo"}