Nodes/comfy-ovum/_.groupBy
ComfyUI Node

_.groupBy

_.groupBy is the genuinely useful one

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.groupBy
  • list_or_dict
  • iteratee
  • DICT
iteratee_json

_.groupBy splits a collection into buckets. You give it a list and a key (or a function), and you get back a dict where each unique key points to the sub-list of items that share it. It's the pivot-table move of the underscore family, and it's one of the few nodes here I'd call genuinely useful.

It's one of the _.* nodes in sfinktah/comfy-ovum, the auto-generated wrappers around underscore3 (a Python port of Underscore.js). Display name _.groupBy, class UnderscoreGroupBy.

How the iteratee works

The grouping key comes from an iteratee, and the shorthand rules are the good part:

  • Property name - if iteratee is a string like "category", items are grouped by the value of that property. That's the beginner-friendly path.
  • Function - a callable gets run per item and its result becomes the group key.
  • Object shorthand - matching against a properties object also works as a key.

So a list of tag dicts [{"name":"hdr","cat":"light"}, {"name":"sunset","cat":"light"}, {"name":"sharp","cat":"detail"}] with iteratee "cat" becomes {"light": [...], "detail": [...]}. Verified against the shipped port - that's exactly the shape you get.

The inputs that matter

  • list_or_dict - the collection to bucket (loose *; also accepts a _.CHAIN).
  • iteratee - the grouping logic, an ANY input.
  • iteratee_json - the practical one. When iteratee isn't connected, this multiline string is parsed as JSON or a selector. Type your property name in quotes, like "cat", and you're done.

Output is typed DICT - the bucket dict, ready to wire into anything that takes a dictionary (or into _.get to pull one bucket back out).

Why you'd reach for it

Grouping is a real workflow need: bucket a batch of generations by seed parity, group images by model, organize tags by category before building a prompt. The typed DICT output is a relief in a family that mostly returns loose *.

Install

ComfyUI Manager, search "comfy-ovum", or:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

Restart, under ovum/underscore. No models, no downloads.

Honest warnings

The README's family disclaimer applies - work in progress, not for production. Remember iteratee_json needs strict JSON: quote your key name ("cat"), not bare cat. And the chain rule: feed a _.CHAIN in, get a chain out; _.value to unwrap the bucket dict.

Categoryovum/underscore

Inputs (3)

NameTypeDefaultDescription
list_or_dictopt*Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
iterateeopt*iteratee: ANY input to override widget. Accepts function, key string, or object shorthand.
iteratee_jsonoptSTRINGiteratee_json: JSON or key selector. Used when 'iteratee' input is not connected.

Outputs (1)

NameTypeDescription
DICTDICT