refactor(__init__.py, debug_civitai.py): update import error handling to use logger for warnings and errors instead of print statements feat(tests): replace print statements with logger calls for better logging in media selection tests feat(install): integrate logging for installation process in install.py feat(cache): implement logging for cache operations in cache.py refactor(debug_utils): enhance debug_print function to use a dedicated logger for consistent debug output feat(helper_nodes.py, lora_hash_cache.py): integrate logging functionality to replace print statements with logger calls for better debugging and monitoring chore(lora_manager): remove deprecated LoRA Manager files as they are no longer needed in the project chore(file_api.py): remove deprecated file API implementation to streamline codebase and reduce maintenance overhead chore(lora_utils.py): remove unused LoRA utility functions to clean up the codebase and improve maintainability chore(nd_super_lora_node.py): remove nd_super_lora_node.py file as it is no longer needed in the project chore(template_manager.py): remove the template management system as it is no longer needed in the project chore(version_utils.py): remove version utility file as it is no longer needed in the project chore(web_api.py): remove deprecated web API endpoints for ND Super Nodes to clean up the codebase and improve maintainability refactor(media_describe.py): replace print statements with logger calls for better logging management and consistency refactor(media_describe.py): replace print statements with logger calls to standardize logging and improve maintainability feat(logging): integrate logging functionality into nodes.py and restart_api.py for better debugging and monitoring - Initialize logging in both files to replace print statements with logger calls. - Use logger to capture debug and info messages for improved traceability.
132 lines
5.4 KiB
Python
132 lines
5.4 KiB
Python
import os
|
|
from nodes.debug_utils import setup_logging, get_logger
|
|
|
|
setup_logging()
|
|
logger = get_logger(__name__)
|
|
from .nodes.nodes import NODE_CLASS_MAPPINGS as MAIN_NODE_CLASS_MAPPINGS
|
|
from .nodes.nodes import NODE_DISPLAY_NAME_MAPPINGS as MAIN_NODE_DISPLAY_NAME_MAPPINGS
|
|
from .nodes.helper_nodes import HELPER_NODE_CLASS_MAPPINGS
|
|
from .nodes.helper_nodes import HELPER_NODE_DISPLAY_NAME_MAPPINGS
|
|
|
|
# Import control panel node
|
|
try:
|
|
from .nodes.utils.control_panel import CONTROL_PANEL_NODE_CLASS_MAPPINGS
|
|
from .nodes.utils.control_panel import CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import control panel node: {e}")
|
|
CONTROL_PANEL_NODE_CLASS_MAPPINGS = {}
|
|
CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Import civit metadata helper node
|
|
try:
|
|
from .nodes.utils.civit_metadata_helper import CIVIT_METADATA_HELPER_NODE_CLASS_MAPPINGS
|
|
from .nodes.utils.civit_metadata_helper import CIVIT_METADATA_HELPER_NODE_DISPLAY_NAME_MAPPINGS
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import civit metadata helper node: {e}")
|
|
CIVIT_METADATA_HELPER_NODE_CLASS_MAPPINGS = {}
|
|
CIVIT_METADATA_HELPER_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Import Azure Storage Upload node
|
|
try:
|
|
from .nodes.utils.azure_storage_upload import NODE_CLASS_MAPPINGS as AZURE_STORAGE_NODE_CLASS_MAPPINGS
|
|
from .nodes.utils.azure_storage_upload import NODE_DISPLAY_NAME_MAPPINGS as AZURE_STORAGE_NODE_DISPLAY_NAME_MAPPINGS
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import Azure Storage Upload node: {e}")
|
|
AZURE_STORAGE_NODE_CLASS_MAPPINGS = {}
|
|
AZURE_STORAGE_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Import lora_manager nodes
|
|
try:
|
|
from .nodes.lora_manager import NODE_CLASS_MAPPINGS as LORA_MANAGER_NODE_CLASS_MAPPINGS
|
|
from .nodes.lora_manager import NODE_DISPLAY_NAME_MAPPINGS as LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import lora_manager nodes: {e}")
|
|
LORA_MANAGER_NODE_CLASS_MAPPINGS = {}
|
|
LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Import media_selection nodes
|
|
try:
|
|
from .nodes.media_selection.media_selection import MediaSelection
|
|
from .nodes.media_selection.frame_extractor import FrameExtractor
|
|
from .nodes.media_selection.multi_caption_combiner import MultiCaptionCombiner
|
|
|
|
MEDIA_SELECTION_NODE_CLASS_MAPPINGS = {
|
|
"MediaSelection": MediaSelection,
|
|
"FrameExtractor": FrameExtractor,
|
|
"MultiCaptionCombiner": MultiCaptionCombiner,
|
|
}
|
|
MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"MediaSelection": "Media Selection",
|
|
"FrameExtractor": "Frame Extractor",
|
|
"MultiCaptionCombiner": "Multi-Caption Combiner",
|
|
}
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import media_selection nodes: {e}")
|
|
MEDIA_SELECTION_NODE_CLASS_MAPPINGS = {}
|
|
MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Import vace_annotators nodes
|
|
try:
|
|
from .nodes.vace_annotators import NODE_CLASS_MAPPINGS as VACE_ANNOTATORS_NODE_CLASS_MAPPINGS
|
|
from .nodes.vace_annotators import NODE_DISPLAY_NAME_MAPPINGS as VACE_ANNOTATORS_NODE_DISPLAY_NAME_MAPPINGS
|
|
except ImportError as e:
|
|
logger.warning(f"Could not import vace_annotators nodes: {e}")
|
|
VACE_ANNOTATORS_NODE_CLASS_MAPPINGS = {}
|
|
VACE_ANNOTATORS_NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
|
|
# Register config API routes
|
|
try:
|
|
from .nodes.config_api import register_config_routes
|
|
from .nodes.restart_api import register_restart_routes
|
|
from server import PromptServer
|
|
app = getattr(PromptServer.instance, "app", None) or PromptServer.instance
|
|
if app:
|
|
register_config_routes(app)
|
|
register_restart_routes(app)
|
|
logger.info("Swiss Army Knife: Registered config API routes")
|
|
except Exception as e:
|
|
logger.error(f"Swiss Army Knife: Could not register config API routes: {e}")
|
|
|
|
|
|
# Get version from pyproject.toml for cache busting
|
|
def get_version():
|
|
try:
|
|
import tomllib
|
|
pyproject_path = os.path.join(os.path.dirname(__file__), "pyproject.toml")
|
|
with open(pyproject_path, "rb") as f:
|
|
data = tomllib.load(f)
|
|
return data["project"]["version"]
|
|
except Exception:
|
|
# Fallback to timestamp if version reading fails
|
|
import time
|
|
return str(int(time.time()))
|
|
|
|
# Combine main nodes, helper nodes, control panel, civit metadata helper, azure storage, lora_manager, media_selection, and vace_annotators nodes
|
|
NODE_CLASS_MAPPINGS = {
|
|
**MAIN_NODE_CLASS_MAPPINGS,
|
|
**HELPER_NODE_CLASS_MAPPINGS,
|
|
**CONTROL_PANEL_NODE_CLASS_MAPPINGS,
|
|
**CIVIT_METADATA_HELPER_NODE_CLASS_MAPPINGS,
|
|
**AZURE_STORAGE_NODE_CLASS_MAPPINGS,
|
|
**LORA_MANAGER_NODE_CLASS_MAPPINGS,
|
|
**MEDIA_SELECTION_NODE_CLASS_MAPPINGS,
|
|
**VACE_ANNOTATORS_NODE_CLASS_MAPPINGS
|
|
}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
**MAIN_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**HELPER_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**CIVIT_METADATA_HELPER_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**AZURE_STORAGE_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS,
|
|
**VACE_ANNOTATORS_NODE_DISPLAY_NAME_MAPPINGS
|
|
}
|
|
|
|
WEB_DIRECTORY = "./web"
|
|
VERSION = get_version()
|
|
|
|
# Load DEBUG setting from environment
|
|
DEBUG = os.environ.get("DEBUG", "false").lower() in ("true", "1", "yes")
|
|
|
|
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY", "VERSION", "DEBUG"] |