Files
Limbicnation-ComfyUI-Prompt…/__init__.py
T
limbicnationandClaude Opus 4.7 e8d781d737 feat: add registration safety guards (mapping self-check + contract tests)
Direct response to the v1.1.6 packaging gap, where the prompt-chain nodes
(combiner, refiner, negative) were authored under nodes/ but never wired
into NODE_CLASS_MAPPINGS, so they silently failed to ship.

- __init__.py now raises RuntimeError at import time if NODE_CLASS_MAPPINGS
  and NODE_DISPLAY_NAME_MAPPINGS drift apart. ComfyUI startup logs surface
  the mismatch instead of dropping the node from the menu silently.
- New tests/unit/test_node_registration.py contract suite (8 tests):
  * Expected 5 keys are registered.
  * Display names cover every class.
  * Each registered class satisfies the ComfyUI node interface
    (INPUT_TYPES classmethod, RETURN_TYPES, FUNCTION, CATEGORY,
    and the FUNCTION attribute resolves to a callable method).
  * Every nodes/*_node.py module on disk is reachable from the mapping —
    this is the regression guard that would have caught v1.1.6.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 06:14:55 +02:00

48 lines
2.0 KiB
Python

"""
ComfyUI Prompt Generator Node
Generate Stable Diffusion prompts using Qwen3-8B via Ollama
"""
try:
from .nodes.negative_prompt_node import NegativePromptNode
from .nodes.prompt_combiner_node import PromptCombinerNode
from .nodes.prompt_generator_node import PromptGeneratorNode
from .nodes.prompt_refiner_node import PromptRefinerNode
from .nodes.style_applier_node import StyleApplierNode
except ImportError:
# Fallback for test environments where ComfyUI isn't present
from nodes.negative_prompt_node import NegativePromptNode
from nodes.prompt_combiner_node import PromptCombinerNode
from nodes.prompt_generator_node import PromptGeneratorNode
from nodes.prompt_refiner_node import PromptRefinerNode
from nodes.style_applier_node import StyleApplierNode
NODE_CLASS_MAPPINGS = {
"Limbicnation_PromptGenerator": PromptGeneratorNode,
"Limbicnation_StyleApplier": StyleApplierNode,
"Limbicnation_PromptRefiner": PromptRefinerNode,
"Limbicnation_NegativePrompt": NegativePromptNode,
"Limbicnation_PromptCombiner": PromptCombinerNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Limbicnation_PromptGenerator": "Prompt Generator (Qwen)",
"Limbicnation_StyleApplier": "Style Applier",
"Limbicnation_PromptRefiner": "Prompt Refiner",
"Limbicnation_NegativePrompt": "Negative Prompt Generator",
"Limbicnation_PromptCombiner": "Prompt Combiner",
}
# Fail loudly at import time if mapping drift occurs — silent omission would just
# remove nodes from the ComfyUI menu without any error in the console.
_missing_display = set(NODE_CLASS_MAPPINGS) - set(NODE_DISPLAY_NAME_MAPPINGS)
_orphan_display = set(NODE_DISPLAY_NAME_MAPPINGS) - set(NODE_CLASS_MAPPINGS)
if _missing_display or _orphan_display:
raise RuntimeError(
"Node mapping mismatch — "
f"missing display names: {sorted(_missing_display)}; "
f"orphan display names: {sorted(_orphan_display)}"
)
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]