54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""Namespaced registrations for the complete vendored H3 upstream packs.
|
|
|
|
The source is kept under ``vendor/`` with its licenses and upstream layout
|
|
intact. This module is the only integration point: every upstream node gets a
|
|
DUMAS-prefixed ComfyUI id so the original packs can remain installed without
|
|
node-id collisions.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import logging
|
|
|
|
|
|
_PACKAGES = (
|
|
(".vendor.dumas_h3_continuum", "H3 Continuum"),
|
|
(".vendor.dumas_minimax_h3_refmod", "MiniMax H3 RefMod"),
|
|
(".vendor.dumas_h3_refmod_picker", "H3 RefMod Picker"),
|
|
)
|
|
|
|
|
|
def _load_pack(package_name):
|
|
try:
|
|
return importlib.import_module(package_name)
|
|
except Exception:
|
|
logging.getLogger("DumasNodes").exception(
|
|
"Could not load vendored upstream pack %s", package_name,
|
|
)
|
|
return None
|
|
|
|
|
|
def _namespaced_mappings():
|
|
mappings = {}
|
|
display = {}
|
|
for relative_name, label in _PACKAGES:
|
|
package_name = (f"{__package__}{relative_name}" if __package__
|
|
else relative_name.lstrip("."))
|
|
pack = _load_pack(package_name)
|
|
if pack is None:
|
|
continue
|
|
source_mappings = getattr(pack, "NODE_CLASS_MAPPINGS", {}) or {}
|
|
source_display = getattr(pack, "NODE_DISPLAY_NAME_MAPPINGS", {}) or {}
|
|
for node_id, node_class in source_mappings.items():
|
|
# Keep upstream IDs so the complete upstream web UI and saved
|
|
# workflows remain functional. The original packs must not also be
|
|
# installed, otherwise ComfyUI will see duplicate node IDs.
|
|
mappings[node_id] = node_class
|
|
original_name = source_display.get(node_id, node_id)
|
|
display[node_id] = f"DUMAS {label} · {original_name}"
|
|
return mappings, display
|
|
|
|
|
|
NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS = _namespaced_mappings()
|