fix(wanvideo): resolve lora path resolution and name truncation for extra folder paths

- Use get_lora_info_absolute to obtain correct absolute paths for loras
  in LM extra folder paths, instead of folder_paths.get_full_path which
  only searches ComfyUI's standard loras directories (returned None)
- Fix name field truncation: str.split('.')[0] stopped at the first dot,
  replaced with os.path.splitext to only strip the file extension
- Add _relpath_within_loras helper to preserve subdirectory info in the
  name field, matching WanVideoWrapper's os.path.splitext(lora)[0] format
This commit is contained in:
Will Miao
2026-05-02 14:55:12 +08:00
parent f028625ce9
commit 2ac0eb0f9d
2 changed files with 34 additions and 10 deletions

View File

@@ -1,10 +1,22 @@
import folder_paths # type: ignore import os
from ..utils.utils import get_lora_info from ..utils.utils import get_lora_info_absolute
from ..config import config
from .utils import FlexibleOptionalInputType, any_type, get_loras_list from .utils import FlexibleOptionalInputType, any_type, get_loras_list
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def _relpath_within_loras(abs_path):
"""Return abs_path relative to the first matching lora root, or basename as fallback."""
all_roots = list(config.loras_roots or []) + list(config.extra_loras_roots or [])
for root in all_roots:
try:
return os.path.relpath(abs_path, root)
except ValueError:
continue
return os.path.basename(abs_path)
class WanVideoLoraSelectLM: class WanVideoLoraSelectLM:
NAME = "WanVideo Lora Select (LoraManager)" NAME = "WanVideo Lora Select (LoraManager)"
CATEGORY = "Lora Manager/stackers" CATEGORY = "Lora Manager/stackers"
@@ -56,13 +68,13 @@ class WanVideoLoraSelectLM:
clip_strength = float(lora.get('clipStrength', model_strength)) clip_strength = float(lora.get('clipStrength', model_strength))
# Get lora path and trigger words # Get lora path and trigger words
lora_path, trigger_words = get_lora_info(lora_name) lora_path, trigger_words = get_lora_info_absolute(lora_name)
# Create lora item for WanVideo format # Create lora item for WanVideo format
lora_item = { lora_item = {
"path": folder_paths.get_full_path("loras", lora_path), "path": lora_path,
"strength": model_strength, "strength": model_strength,
"name": lora_path.split(".")[0], "name": os.path.splitext(_relpath_within_loras(lora_path))[0],
"blocks": selected_blocks, "blocks": selected_blocks,
"layer_filter": layer_filter, "layer_filter": layer_filter,
"low_mem_load": low_mem_load, "low_mem_load": low_mem_load,

View File

@@ -1,11 +1,23 @@
import folder_paths # type: ignore import os
from ..utils.utils import get_lora_info from ..utils.utils import get_lora_info_absolute
from ..config import config
from .utils import any_type from .utils import any_type
import logging import logging
# 初始化日志记录器 # 初始化日志记录器
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def _relpath_within_loras(abs_path):
"""Return abs_path relative to the first matching lora root, or basename as fallback."""
all_roots = list(config.loras_roots or []) + list(config.extra_loras_roots or [])
for root in all_roots:
try:
return os.path.relpath(abs_path, root)
except ValueError:
continue
return os.path.basename(abs_path)
# 定义新节点的类 # 定义新节点的类
class WanVideoLoraTextSelectLM: class WanVideoLoraTextSelectLM:
# 节点在UI中显示的名称 # 节点在UI中显示的名称
@@ -87,12 +99,12 @@ class WanVideoLoraTextSelectLM:
else: else:
continue continue
lora_path, trigger_words = get_lora_info(lora_name_raw) lora_path, trigger_words = get_lora_info_absolute(lora_name_raw)
lora_item = { lora_item = {
"path": folder_paths.get_full_path("loras", lora_path), "path": lora_path,
"strength": model_strength, "strength": model_strength,
"name": lora_path.split(".")[0], "name": os.path.splitext(_relpath_within_loras(lora_path))[0],
"blocks": selected_blocks, "blocks": selected_blocks,
"layer_filter": layer_filter, "layer_filter": layer_filter,
"low_mem_load": low_mem_load, "low_mem_load": low_mem_load,