Files
kunail0804-ComfyUI-Scene-Co…/__init__.py
T
0de9b43d7a feat(nodes): add the Scene Analyzer ComfyUI node (#19) (#63)
Expose the Scene Analyzer as a ComfyUI node (MASTER_SPEC §20) plus the node
registration plumbing and a shared output adapter.

- nodes/scene_analyzer_node.py: SceneAnalyzerNode, a thin adapter. Inputs are
  Natural Language, Model Name, Temperature, Timeout, and an optional System
  Prompt override; it builds a Config, constructs OllamaBackend.from_config, and
  delegates to analyze(). Outputs (scene, warnings, errors): the SCENE model and
  the warnings/errors formatted for display. No compiler logic in the node.
- nodes/adapters.py: format_messages() renders diagnostics as CODE: description
  lines.
- Registration: nodes/__init__.py aggregates NODE_CLASS_MAPPINGS /
  NODE_DISPLAY_NAME_MAPPINGS; the root __init__.py re-exports them.

ComfyUI compatibility: the node package uses relative imports internally so our
`nodes` package is never resolved as ComfyUI's own top-level `nodes` module, and
the entry point puts the repo root on sys.path so `compiler`/`schemas` resolve
when ComfyUI loads the package by file path.

Tests (no live Ollama): INPUT_TYPES/RETURN metadata, delegation to analyze
(monkeypatched) with warnings/errors surfaced, empty-message strings, system
prompt override passthrough, and ComfyUI registration.

Co-authored-by: kunail0804 <kunail0804@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 14:08:03 +02:00

29 lines
1.2 KiB
Python

"""ComfyUI Scene Compiler — ComfyUI custom node entry point.
ComfyUI loads this module by path and reads ``NODE_CLASS_MAPPINGS`` /
``NODE_DISPLAY_NAME_MAPPINGS`` to register the compiler's nodes. The mappings are
aggregated in the ``nodes`` package; the compiler logic lives entirely in the
``compiler`` package, which never imports ComfyUI.
The ``compiler`` and ``schemas`` packages are imported by their top-level names,
so this entry point puts the repository root on ``sys.path`` when ComfyUI loads it
by file path. The ``nodes`` package is only ever imported relative to this
package (never as a top-level ``nodes``), so it does not collide with ComfyUI's
own core ``nodes`` module.
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
try:
# ComfyUI loads this file inside a package, so the relative import resolves.
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
except ImportError:
# Imported standalone (e.g. by the test runner): fall back to the top-level
# package that is on sys.path.
from nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]