Nodes/ComfyUI-LogicUtils/Pyobjects/Set Add
ComfyUI Node

Pyobjects/Set Add

Add one item to a Python set, ComfyUI-native

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/Set Add
  • py_set
  • item
  • SET

Set Add (SetAddNode) does exactly what Python's set.add() does: takes a set and an item, and hands back a set that includes it. Duplicates are automatically a non-event - add the same value twice and the set doesn't grow - which is the whole reason you'd reach for a set instead of a list in the first place: automatic deduplication, no manual "is this already in here?" check needed.

It's part of aria1th's ComfyUI-LogicUtils pack - a personal utility library from the same handle that trained Illustrious XL, ported the whole of Python's set algebra into graph nodes (Create, Add, Remove, Clear, Union, Intersection, Difference, Symmetric Difference, Set to List). It's a niche pack with essentially no community footprint online, but the mechanics are exactly what they say on the tin: real set objects, not an approximation.

How it works

You feed it a SET (from Set Create or an earlier point in the chain) and an item of any type. It runs set.add(item) under the hood and outputs the resulting SET. Because ComfyUI graphs are directed and mutation-by-reference gets messy fast, the node returns a fresh set reference each time rather than silently mutating the one you passed in - treat it the same way you'd treat any functional-style node: the output is the new state, wire that forward, don't assume the input set changed in place.

Chain several of these to build up a set item by item - one per value - which is the pattern you'll actually use it in: dedupe a batch of prompt tags, collect unique seeds you've already tried, or build a "seen" set across a loop that later feeds a Set Difference to find what's new.

Inputs and outputs

  • py_set (SET, required) - the set you're adding to.
  • item (any type, required) - the value to add. LogicUtils leaves this untyped on purpose so you can add a string, a number, or anything else the item happens to be.
  • Output: SET - the set with item added (or unchanged, if it was already a member).

How to install it

ComfyUI Manager → search "ComfyUI-LogicUtils" → install → restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils

then restart ComfyUI. No models, no GPU cost - it's a Python set operation, done on CPU in effectively zero time.

Common issues & troubleshooting

"Missing node type" on a shared workflow. Let ComfyUI Manager's "Install Missing Custom Nodes" resolve the whole pack from the graph JSON rather than hunting down SetAddNode by hand.

Import errors at startup. The pack's auto-installer for its own dependencies is opt-in, per the README: set COMFYUI_LOGICUTILS_AUTO_INSTALL=1 before launch if something didn't get pulled in, or COMFYUI_LOGICUTILS_SKIP_INSTALL=1 to disable the hook entirely if it's the one causing the error. SetAddNode itself needs nothing beyond the Python standard library, so a dependency error here almost always traces back to a different node in the pack.

"Item not being added" / set looks unchanged. Check whether the item is actually a duplicate - a set silently ignoring a repeat isn't a bug, it's the feature. If you need to count occurrences instead of just recording membership, a set is the wrong tool; you'd want a list or a dict-based counter instead.

Type mismatch downstream. SET only connects to LogicUtils' own set nodes. If you need the contents somewhere that expects a plain LIST - a for-loop node, a display widget - run it through Set to List first.

CategoryData

Inputs (2)

NameTypeDefaultDescription
py_setSET
item*

Outputs (1)

NameTypeDescription
SETSET