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

Pyobjects/Set Union

Merge two sets, duplicates handled for free

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/Set Union
  • py_set_a
  • py_set_b
  • SET

Set Union (SetUnionNode) takes two sets and merges them: every item that's in A, or in B, or in both, ends up in the output - once each. It's the node you reach for when you've built two separate collections (say, tags approved by two different filters, or seeds tried across two runs) and want the combined pool without hand-rolling a dedupe pass.

Part of aria1th's ComfyUI-LogicUtils, the Illustrious XL trainer's personal utility pack. It's a niche, thinly-documented library - the README's honest self-assessment is that "proper documentation is being prepared, however there are too many nodes" - but the set-operations cluster it ships (Create, Add, Remove, Clear, Union, Intersection, Difference, Symmetric Difference, Set to List) is a complete, faithful port of Python's set algebra.

How it works

Under the hood it's py_set_a | py_set_b, Python's set union operator. No configuration, no ordering guarantees - sets are unordered by definition, so don't build logic that depends on which set's items come "first" in the result. If both operands share an item, it appears exactly once in the output, which is the whole appeal versus concatenating two lists and hoping nothing downstream cares about repeats.

A practical pattern: build set A from one branch of your workflow, set B from another (each via Set Create + a chain of Set Add), then union them at the point where the branches converge, rather than merging raw strings and re-splitting.

Inputs and outputs

  • py_set_a (SET, required) - the first set.
  • py_set_b (SET, required) - the second set.
  • Output: SET - every item present in either set, no duplicates.

How to install it

ComfyUI Manager: search "ComfyUI-LogicUtils", install, restart. Manually:

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

then restart ComfyUI. No model weights involved - this runs on CPU as a plain Python operation and costs nothing in GPU time.

Common issues & troubleshooting

"Missing node type" on a downloaded workflow. ComfyUI Manager's "Install Missing Custom Nodes" resolves the whole pack from the workflow JSON in one go.

Import errors at startup. The README documents an opt-in dependency installer for the pack: set COMFYUI_LOGICUTILS_AUTO_INSTALL=1 before launching ComfyUI if something didn't get installed automatically, or COMFYUI_LOGICUTILS_SKIP_INSTALL=1 to disable that hook if it's the source of trouble. SetUnionNode itself needs nothing beyond the standard library - an import error here is a sign the problem is elsewhere in the pack.

Result looks smaller than expected. That's usually the dedup working as intended, not a bug - if A and B overlap heavily, the union won't be much bigger than either input alone. Check for that before assuming an item got dropped.

Can't feed the result into a non-LogicUtils node. SET only speaks to this pack's own nodes. Run the output through Set to List to get a plain LIST that the rest of ComfyUI understands.

CategoryData

Inputs (2)

NameTypeDefaultDescription
py_set_aSET
py_set_bSET

Outputs (1)

NameTypeDescription
SETSET