Files
2025-10-11 17:08:25 +08:00

49 lines
1.4 KiB
Python

import os
import sys
import importlib
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger("ComfyDeploy")
try:
from . import custom_routes
logger.info("[ComfyDeploy] custom routes successfully initialized")
except Exception as e:
logger.error(f"[ComfyDeploy] custom routes initialization failed: {str(e)}")
sys.path.append(os.path.join(os.path.dirname(__file__)))
ag_path = os.path.join(os.path.dirname(__file__))
def get_python_files(_path):
return [f[:-3] for f in os.listdir(_path) if f.endswith(".py")]
def append_to_sys_path(_path):
if _path not in sys.path:
sys.path.append(_path)
paths = ["nodes"]
files = []
for path in paths:
full_path = os.path.join(ag_path, path)
append_to_sys_path(full_path)
files.extend(get_python_files(full_path))
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
# Import all the modules and append their mappings
for file in files:
module = importlib.import_module(file)
if hasattr(module, "NODE_CLASS_MAPPINGS"):
NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS"):
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
WEB_DIRECTORY = "./js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]