ComfyUI Node

is subset

Is every element of A inside B? The containment check

By StableLlama·Created about a year ago·Updated 4 days ago· 48
is subset
  • set1
  • set2
  • is_subset

is subset checks whether set1 is entirely contained in set2 - every element of the first must exist in the second. If it is, you get True; if even one element is missing from set2, False. It's a boolean gate that answers "is this pool a sub-pool of that one?"

This is a genuinely useful thing to be able to ask in a workflow. You might want to verify that a set of required tags is fully covered by a prompt's tag set before generation, confirm that a filter list you built is a valid subset of the available options, or gate a fallback branch on "everything we need is present." The output is a plain BOOLEAN, so it plugs straight into the pack's if/else or flow select control nodes - no extra plumbing.

How it works

The mechanism is Python's set1.issubset(set2): every element of set1 is tested for membership in set2, and the result is a single boolean. Nothing is copied, nothing is mutated - it's a pure read operation, so it costs almost nothing in a graph.

A couple of Python semantics to keep straight:

  • A set is a subset of itself. {1, 2}{1, 2} is True. If you need "strictly smaller," compare length values too.
  • The empty set is a subset of everything. An empty set1 returns True against any set2, including another empty set. Fine in most cases, but it can mask a "you forgot to fill this in" bug - check length if an empty input would be a mistake.

Inputs and output

  • set1 (SET) - the candidate subset.
  • set2 (SET) - the set it's checked against.
  • is_subset (BOOLEAN, output) - True when every element of set1 is in set2.

Two required inputs, one boolean out. Note the direction: set1 is the one being contained. If you get the pairing backwards you're really asking the is superset question.

Installing

It ships in Basic data handling by StableLlama. The easy route is ComfyUI Manager - search "Basic data handling", install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart after cloning. Zero dependencies, no model downloads - pure Python, so it's a frictionless install.

Common issues

The main confusion is direction. is subset asks "is set1 inside set2," which is the mirror of is superset ("does set1 contain all of set2"). Swapping which set you think is the container gives you the wrong node. And remember membership is exact: values that differ by case or type won't count as contained, so normalize your sets first if your data is messy.

CategoryBasic/SET

Inputs (2)

NameTypeDefaultDescription
set1SET
set2SET

Outputs (1)

NameTypeDescription
is_subsetBOOLEAN