ComfyUI Node

_.get

_.get, and the deep-path claim to be wary of

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.get
  • py_dict
  • default
  • *
path

_.get pulls a property off an object without crashing when it's missing. Give it a dict and a key, and you get the value back - or a default you supply when the key doesn't exist. It's the defensive way to read fields out of nested data, and if you're digging through workflow metadata or config JSON, it's the node in this family most worth knowing.

It's one of the _.* nodes in sfinktah/comfy-ovum, wrapping underscore3 (a Python port of Underscore.js). Display name _.get, class UnderscoreGet.

The inputs that matter

  • py_dict - the object to read from (loose *; also accepts a _.CHAIN).
  • path - the property name, as a plain STRING widget. This is the one you type.
  • default - an ANY fallback, JSON allowed, returned when the key is missing.

Output is a loose *: the value, or the default, or None.

The deep-path caveat - read this

The node's description promises lodash-style deep fetching: "path may be specified as a simple key, or as an array of object keys or array indexes, for deep property fetching." I tested that against the actual shipped code, and the port's get is a simple single-key lookup - obj.get(key) for dicts, getattr otherwise. A dot-path like "meta.score" on a nested dict returns None (it looks for a literal "meta.score" key), and passing an array path actually raises TypeError: unhashable type: 'list'. So treat path as a single key today. Deep access is aspirational - another sign this family is a work in progress.

Why you'd reach for it

Anywhere you read a field you're not 100% sure exists. The default input is the star: _.get on a metadata dict with default: "unknown" won't kill your run when a key's absent - it substitutes. For shallow, single-key reads with a safety net, it does the job cleanly.

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

Family disclaimer applies. The big one is the deep-path gap above - don't feed it "a.b.c" and expect nested magic. And the chain rule: feed a _.CHAIN in, get a chain out; _.value to unwrap before using the result.

Categoryovum/underscore

Inputs (3)

NameTypeDefaultDescription
py_dictopt*Primary input object (expected object). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining.
pathoptSTRINGpath (string)
defaultopt*default: JSON allowed for arrays/objects where applicable.

Outputs (1)

NameTypeDescription
**