Files
EthanfelandClaude Fable 5 106f036da6 feat(inline): stamp LoRA filenames onto the model via a LoraLoader wrapper (stock + rgthree Power Loader)
Add _install_lora_name_stamp(), which idempotently wraps
nodes.LoraLoader.load_lora so every stock/rgthree LoRA load records its
real filename + strengths as an ordered "loraopt_chain_names" attachment
on the returned model (and clip.patcher). One method covers all three
loaders: stock LoraLoader (direct), LoraLoaderModelOnly (via self.load_lora),
and rgthree PowerLoraLoader (via LoraLoader().load_lora, whose LoraLoader
IS nodes.LoraLoader).

The accumulator builds a NEW list every call because ModelPatcher.clone
copies the attachment list by reference; appending in place would corrupt
the upstream (pre-clone) model's chain. Stamping is fully fail-safe: any
error returns the original load result unchanged. __init__ installs the
wrapper at import (idempotent, graceful when comfy's `nodes` is absent).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 18:28:50 +02:00

26 lines
983 B
Python

"""ComfyUI-LoRA-Optimizer — auto-optimizer for multi-LoRA merging."""
try:
from .lora_optimizer import (NODE_CLASS_MAPPINGS,
NODE_DISPLAY_NAME_MAPPINGS,
_install_lora_name_stamp)
except ImportError:
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
_install_lora_name_stamp = None
# Wrap nodes.LoraLoader.load_lora so stock + rgthree LoRA loads stamp their
# real filenames onto the model/clip — the inline optimizer reads them back
# to show real names, attribute per-LoRA, and reconcile with the file-based
# community dataset. Fail-safe: never break node registration if comfy's
# `nodes` module isn't importable yet (idempotent — safe to call repeatedly).
if _install_lora_name_stamp is not None:
try:
_install_lora_name_stamp()
except Exception:
pass
WEB_DIRECTORY = "./js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]