ComfyUI Node

FEDictUnpacker

Pull named fields out of a dictionary

By fexli·Created 3 years ago·Updated about a year ago· 3
FEDictUnpacker
  • input_dict
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
  • field
out_fielda,b

FEDictUnpacker does for dictionaries what FEDataUnpacker does for lists: one dict in, and each field you name comes out on its own output socket. You tell it which keys you want with a comma-separated string - a,b by default - and the node hands you input_dict["a"] on one output, input_dict["b"] on another.

It's the natural consumption side of the pack's dict machinery. FEDictPacker builds a named dict, FEDictCombine merges dicts, FEAnyToDict wraps values into dicts - and when you finally need the values back out as separate wires, this is the exit. Type a field name, get a value. You don't have to name all the dict's keys, only the ones you want; the outputs are dynamic, trimmed to what you've connected, so you see exactly the fields you asked for.

The inputs

  • input_dict - *-typed, the dictionary to read from.
  • out_field - the comma-separated key names, default "a,b".

Outputs are named field, type *, one per key in out_field, in the order you listed them. Wire each to its consumer.

The gotchas are the same family as the rest of the pack but worth stating plainly:

  • Keys must exist. The code does input_dict.get(key) - a missing key gives you None on the wire, silently. If a field name is typo'd or the upstream dict didn't set it, you get a null flowing into a node that then throws somewhere else. There's no error here, and that's the trap.
  • Spacing matters. a, b yields a key of " b" because it splits on commas without trimming. Write a,b.
  • *-type flexibility cuts both ways. It'll accept anything as input_dict; if what arrives isn't actually a dict, get fails loudly at execution time.

The pairing with FEDictPacker is the headline use: pack data in one place, ship it around as a single wire, unpack it where it's needed. It keeps the graph from becoming a spaghetti of parallel wires, which is worth a lot in a big workflow. Just remember that named access is only as reliable as the upstream keys - verify the field names match exactly.

Categoryfexli/utils

Inputs (2)

NameTypeDefaultDescription
input_dict*
out_fieldSTRINGa,b

Outputs (32)

NameTypeDescription
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*
field*