Nodes/ASTERR/ASTERR Script
ComfyUI Node

ASTERR Script

Run Real Python Inside Your ComfyUI Graph — Just Mind the Fire Extinguisher

By WASasquatch·Created 3 years ago·Updated 2 years ago· 29
ASTERR Script
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • k
  • result
script
trigger_run_01
preset_script
always_run

ASTERR is the node you reach for when no existing node does the thing, and you know Python. It's an arbitrary Python interpreter inside your workflow - write a multiline script in a text box, pass in images, models, numbers, whatever as variables, and get a result back out on the other side. Same author as the famous WAS Node Suite, which tells you the pedigree: WASasquatch has been shipping ComfyUI utilities since the early days, and this is his entry in the small genre of "just let me run code" nodes.

The name is a strained acronym - Abstract Syntax Trees Evaluated Restricted Run - but the "Restricted" part is doing real work. ComfyUI runs custom node Python with full user-level OS access and no sandbox (the community learned that the hard way with the ComfyUI_LLMVISION malware incident). So before it runs anything, ASTERR parses your script into an abstract syntax tree and walks it, checking every import and from statement against an allowlist. Out of the box that's ComfyUI's own nodes and folder_paths, plus math, random, time, numpy, PIL and cv2. The rest of the script executes with plain exec(), so this is a speed bump, not a cage - which is exactly why the README's first sentence is a warning to run it in a closed-off environment.

The input that matters is script (multiline STRING). Then come the fun ones: a through k, eleven wildcard inputs that accept any type - STRING, INT, FLOAT, IMAGE, MODEL, whatever you wire in - and land in your script as variables of the same name. If a is an image, expect a batched tensor and handle it accordingly; the node injects two helpers, tensor2pil() and pil2tensor(), so image round-tripping is one line each. Whatever you assign to the asterr_result variable at the end of the script is what the result output returns. preset_script swaps in a saved .py from the pack's scripts/ folder (overriding your inline text), and always_run / trigger_run_01 decide when it executes - leave always_run false and it only reruns when its inputs change; flip it true or set trigger_run_01 to 1 and it re-executes on every queue, which is what you want when the script's job is a side effect like moving files. You can even overwrite extra_pnginfo inside the script to inject metadata into the saved PNG.

To install: Manager (search "ASTERR") or

cd ComfyUI/custom_nodes && git clone https://github.com/WASasquatch/ASTERR

then restart. There are no model downloads and no heavyweight requirements - it's stdlib-only plus what ComfyUI already has. You can tune config.json in the pack folder for recursion_limit (100 by default) and allowed_modules (use ["PIL.*"] for a module and its submodules, or ["*"] to live dangerously).

Where people get burned: a typo surfaces as a NameError straight on the node, which is at least honest. Trying to import something off-allowlist throws a clean ImportError - add it to config.json rather than fighting it. And remember the security reality: any machine with this workflow loaded and editable is a machine whose file system and network are one script away. Keep ComfyUI off the public internet, don't load strangers' workflows that use it, and treat ["*"] as the "I know exactly what I'm doing" button it is.

Category_for_testing

Inputs (15)

NameTypeDefaultDescription
scriptSTRING
trigger_run_01optINT
aopt*
bopt*
copt*
dopt*
eopt*
fopt*
gopt*
hopt*
iopt*
jopt*
kopt*
preset_scriptoptCOMBO2 options: None, resize_maxsize.py
always_runoptCOMBO2 options: false, true

Outputs (1)

NameTypeDescription
result*