Files
eric-venti-seeds-Sphere-Lig…/tools/test_inputs.py
T
Christopher Connock e53f000286 feat: client-side graph-driven inputs (replace the browser round-trip)
The server round-trip (render_bridge + is_driven + send_sync + POST) could never
detect the common driver: ComfyUI inlines a Primitive's value as a literal in the
prompt and strips the node, so is_driven (which looks for a [id,slot] link) was
blind to it — nothing drove. Proven in a live ComfyUI via browser automation.

Replace it with a client-side approach:
- getAngles() reads a connected input's value by following the graph link to its
  source (Primitive/static), else the widget — a connection wins over the control.
- A graphToPrompt wrapper refreshes each node's render_b64 from current values
  before every run, so the driven value (incl. increment animation) is baked into
  the image for that queue. execute() just decodes render_b64, unchanged.
- heading/city (hidden behind the compass/search overlays) are auto-exposed as
  input sockets via convertWidgetToInput, guarded against reload double-convert;
  their manual controls still drive when unconnected. Persistence verified across
  save/reload.

Removes render_bridge.py, js/driven.js, is_driven, the hidden node_id/prompt
inputs, renderWith, and their tests. Verified end-to-end (real queue, output
brightness tracks driven intensity 0.3->133, 3.0->255) in the live ComfyUI.
2026-07-09 21:10:23 -04:00

29 lines
1.2 KiB
Python

import sys, types, importlib.util, os, numpy as np
faketorch = types.ModuleType("torch")
class FT:
def __init__(self, a): self.a = a
def unsqueeze(self, d): return FT(np.expand_dims(self.a, d))
@property
def shape(self): return self.a.shape
faketorch.from_numpy = lambda a: FT(a)
sys.modules["torch"] = faketorch
NODE = os.path.join(os.path.dirname(__file__), "..", "__init__.py")
spec = importlib.util.spec_from_file_location("slnode", NODE)
mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)
req = mod.SphereLightNode.INPUT_TYPES()["required"]
for k in ["sun_mode", "location_mode", "location", "latitude", "longitude",
"year", "month", "day", "hour", "minute", "heading"]:
assert k in req, f"missing input: {k}"
assert req["sun_mode"][0] == ["manual", "date/time"], req["sun_mode"]
assert req["location_mode"][0] == ["city", "coords"], req["location_mode"]
# execute must still work and ignore the new params (empty render_b64 -> gray)
node = mod.SphereLightNode()
(t,) = node.execute("manual", 0.0, 45.0, 1.5, "city", "Austin, TX", 0.0, 0.0,
2025, 6, 21, 12, 0, 0.0, "")
assert tuple(t.shape) == (1, 1024, 1024, 3), t.shape
print("test_inputs: OK")