refactor: unify logging across all LoRA nodes
Remove debug print statements from 6 node files. Gate Key Diffusion per-key mapping logs behind NUNCHAKU_LOG_ENABLED env var. Status logs remain always-on.
This commit is contained in:
+14
-17
@@ -14,9 +14,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] qwenimage.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'qwenimage.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
@@ -106,7 +103,7 @@ class NunchakuQwenImageLoraLoader:
|
||||
detection = _detect_lora_format(lora_state_dict)
|
||||
_log_lora_format_detection(str(lora_name), detection)
|
||||
# First LoRA: Detailed key inspection (same as zimageturbo_v4.py lines 219-240)
|
||||
print(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {lora_strength}) ---")
|
||||
logger.info(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {lora_strength}) ---")
|
||||
_first_detection = _detect_lora_format(lora_state_dict)
|
||||
if _first_detection["has_standard"]:
|
||||
for key in lora_state_dict.keys():
|
||||
@@ -114,14 +111,14 @@ class NunchakuQwenImageLoraLoader:
|
||||
if parsed_res:
|
||||
group, base_key, comp, ab = parsed_res
|
||||
mapped_name = f"{base_key}.{comp}.{ab}" if comp and ab else (f"{base_key}.{ab}" if ab else base_key)
|
||||
print(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
logger.info(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
else:
|
||||
print(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
logger.warning(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
else:
|
||||
print("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
print(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
print(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
print("--- DEBUG: End key inspection ---")
|
||||
logger.warning("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
logger.warning(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
logger.warning(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
logger.info("--- DEBUG: End key inspection ---")
|
||||
|
||||
model_wrapper = model.model.diffusion_model
|
||||
|
||||
@@ -322,7 +319,7 @@ class NunchakuQwenImageLoraStack:
|
||||
detection = _detect_lora_format(lora_state_dict)
|
||||
_log_lora_format_detection(str(_fn), detection)
|
||||
# First LoRA: Detailed key inspection (same as zimageturbo_v4.py lines 219-240)
|
||||
print(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
logger.info(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
_first_detection = _detect_lora_format(lora_state_dict)
|
||||
if _first_detection["has_standard"]:
|
||||
for key in lora_state_dict.keys():
|
||||
@@ -330,14 +327,14 @@ class NunchakuQwenImageLoraStack:
|
||||
if parsed_res:
|
||||
group, base_key, comp, ab = parsed_res
|
||||
mapped_name = f"{base_key}.{comp}.{ab}" if comp and ab else (f"{base_key}.{ab}" if ab else base_key)
|
||||
print(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
logger.info(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
else:
|
||||
print(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
logger.warning(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
else:
|
||||
print("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
print(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
print(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
print("--- DEBUG: End key inspection ---")
|
||||
logger.warning("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
logger.warning(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
logger.warning(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
logger.info("--- DEBUG: End key inspection ---")
|
||||
|
||||
model_wrapper = model.model.diffusion_model
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] qwenimage.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'qwenimage.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] qwenimage.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'qwenimage.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
@@ -148,7 +145,7 @@ class NunchakuQwenImageLoraStackV2:
|
||||
detection = _detect_lora_format(lora_state_dict)
|
||||
_log_lora_format_detection(str(_fn), detection)
|
||||
# First LoRA: Detailed key inspection (same as zimageturbo_v4.py lines 219-240)
|
||||
print(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
logger.info(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
_first_detection = _detect_lora_format(lora_state_dict)
|
||||
if _first_detection["has_standard"]:
|
||||
for key in lora_state_dict.keys():
|
||||
@@ -156,14 +153,14 @@ class NunchakuQwenImageLoraStackV2:
|
||||
if parsed_res:
|
||||
group, base_key, comp, ab = parsed_res
|
||||
mapped_name = f"{base_key}.{comp}.{ab}" if comp and ab else (f"{base_key}.{ab}" if ab else base_key)
|
||||
print(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
logger.info(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
else:
|
||||
print(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
logger.warning(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
else:
|
||||
print("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
print(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
print(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
print("--- DEBUG: End key inspection ---")
|
||||
logger.warning("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
logger.warning(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
logger.warning(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
logger.info("--- DEBUG: End key inspection ---")
|
||||
|
||||
model_wrapper = model.model.diffusion_model
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] qwenimage.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'qwenimage.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
@@ -186,7 +183,7 @@ class NunchakuQwenImageLoraStackV2:
|
||||
detection = _detect_lora_format(lora_state_dict)
|
||||
_log_lora_format_detection(str(_fn), detection)
|
||||
# First LoRA: Detailed key inspection (same as zimageturbo_v4.py lines 219-240)
|
||||
print(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
logger.info(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {_fs}) ---")
|
||||
_first_detection = _detect_lora_format(lora_state_dict)
|
||||
if _first_detection["has_standard"]:
|
||||
for key in lora_state_dict.keys():
|
||||
@@ -194,14 +191,14 @@ class NunchakuQwenImageLoraStackV2:
|
||||
if parsed_res:
|
||||
group, base_key, comp, ab = parsed_res
|
||||
mapped_name = f"{base_key}.{comp}.{ab}" if comp and ab else (f"{base_key}.{ab}" if ab else base_key)
|
||||
print(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
logger.info(f"Key: {key} -> Mapped to: {mapped_name} (Group: {group})")
|
||||
else:
|
||||
print(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
logger.warning(f"Key: {key} -> UNMATCHED (Ignored)")
|
||||
else:
|
||||
print("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
print(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
print(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
print("--- DEBUG: End key inspection ---")
|
||||
logger.warning("⚠️ Unsupported LoRA format detected (No standard keys).")
|
||||
logger.warning(f" Skipping detailed key inspection of {len(lora_state_dict)} keys to prevent console freeze.")
|
||||
logger.warning(" Note: This LoRA will likely have no effect or will be skipped entirely.")
|
||||
logger.info("--- DEBUG: End key inspection ---")
|
||||
|
||||
model_wrapper = model.model.diffusion_model
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] zimageturbo.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'zimageturbo.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
lora_loader_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
print(f"[DEBUG] Added to sys.path: {lora_loader_dir}")
|
||||
print(f"[DEBUG] wrappers dir exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers'))}")
|
||||
print(f"[DEBUG] zimageturbo.py exists: {os.path.exists(os.path.join(lora_loader_dir, 'wrappers', 'zimageturbo.py'))}")
|
||||
|
||||
import folder_paths
|
||||
|
||||
@@ -190,7 +187,7 @@ class NunchakuZImageTurboLoraStackV2:
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
|
||||
from nunchaku_code.lora_qwen import _classify_and_map_key, _load_lora_state_dict, _detect_lora_format
|
||||
from nunchaku_code.lora_qwen import _classify_and_map_key, _load_lora_state_dict, _detect_lora_format, NUNCHAKU_LOG_ENABLED
|
||||
except ImportError as e:
|
||||
logger.warning(f"Failed to import mapping debug functions: {e}")
|
||||
logger.warning("Mapping debug logs will be skipped.")
|
||||
@@ -199,7 +196,7 @@ class NunchakuZImageTurboLoraStackV2:
|
||||
_detect_lora_format = None
|
||||
|
||||
# DEBUG: Inspect all keys in the first LoRA (mapping debug logs)
|
||||
if loras_to_apply and _classify_and_map_key and _load_lora_state_dict and _detect_lora_format:
|
||||
if loras_to_apply and _classify_and_map_key and _load_lora_state_dict and _detect_lora_format and NUNCHAKU_LOG_ENABLED:
|
||||
first_lora_name, first_lora_strength = loras_to_apply[0]
|
||||
try:
|
||||
first_lora_path = folder_paths.get_full_path_or_raise("loras", first_lora_name)
|
||||
|
||||
@@ -177,7 +177,7 @@ class NunchakuZImageTurboLoraStackV4:
|
||||
if lora_loader_dir not in sys.path:
|
||||
sys.path.insert(0, lora_loader_dir)
|
||||
|
||||
from nunchaku_code.lora_qwen import _classify_and_map_key, _load_lora_state_dict, _detect_lora_format, _log_lora_format_detection
|
||||
from nunchaku_code.lora_qwen import _classify_and_map_key, _load_lora_state_dict, _detect_lora_format, _log_lora_format_detection, NUNCHAKU_LOG_ENABLED
|
||||
except ImportError as e:
|
||||
logger.warning(f"Failed to import mapping debug functions: {e}")
|
||||
logger.warning("Mapping debug logs will be skipped.")
|
||||
@@ -217,7 +217,7 @@ class NunchakuZImageTurboLoraStackV4:
|
||||
pass
|
||||
|
||||
# First LoRA: Detailed key inspection (same as v3 compose_loras_v2)
|
||||
if idx == 0:
|
||||
if idx == 0 and NUNCHAKU_LOG_ENABLED:
|
||||
logger.info(f"--- DEBUG: Inspecting keys for LoRA 1 (Strength: {lora_strength}) ---")
|
||||
|
||||
# Check format first (same optimization as v3)
|
||||
|
||||
Reference in New Issue
Block a user