Nodes/0nedark-eks-spaghetti/Copy -> Subgraph
ComfyUI Node

Copy -> Subgraph

Turn a group node into a reusable function call

By drupsys·Created 6 months ago·Updated 6 months ago· 0
Copy -> Subgraph
    • out_0
    • out_1
    • out_2
    • out_3
    • out_4
    • out_5
    • out_6
    • out_7
    • out_8
    • out_9
    • out_10
    • out_11
    • out_12
    • out_13
    • out_14
    • out_15
    ref_name

    The odd one out in eks-spaghetti. While the other four nodes hide wires, Copy -> Subgraph (class 0nedark_SubgraphRef) hides a whole region. Select a Group Node from a dropdown and this node turns into a standalone copy of it - same inputs, same outputs, acting as an independent call you can wire anywhere, any number of times, without copy-pasting nodes around the canvas.

    If you've used rgthree or core ComfyUI's group/subgraph feature, the pitch is familiar: collapse a working region, reuse it. The difference here is the word "Copy" in the title. Core ComfyUI's first-party Subgraph shares one definition that all instances feed; this node instead clones the group's nodes into the prompt at queue time, so each instance is a true independent copy - a function call in the programming sense, not a shared reference.

    How it works

    The real work happens in the frontend. This pack patches app.graphToPrompt, and when it sees a SubgraphRef, it finds the named Group Node's expanded node set and clones it under a fresh ID prefix: the ref's inputs get wired into the group's -10 input node, anything feeding the -20 output node is remapped to the ref's outputs, and reroutes that the engine optimized away are chased down and resolved. The backend execute() for this class is essentially a safety net - it returns execution blockers because by the time it would run, the graph has already been rewritten into the clone.

    That's also why it's a "copy" rather than a call to the original: each instance gets its own cloned nodes with their own wiring, so two instances with different inputs don't interfere.

    The inputs and outputs that matter

    • ref_name - a hidden backend field; the visible control is a searchable select_subgraph dropdown listing every Group Node on the canvas.
    • Inputs and out_0 … out_15 - these sync automatically to the group's actual interface (read from the subgraph's -10/-20 IO), names and types included. Wire the group's inputs into the ref's inputs and take outputs out the other side.

    Install

    Search eks-spaghetti (registered as 0nedark-eks-spaghetti) in ComfyUI Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/drupsys/eks-spaghetti
    

    Restart ComfyUI. No extra dependencies, no model downloads.

    Where people get burned

    It's picky about your ComfyUI. Group-node expansion, the -10/-20 IO nodes, and the graph rewriting this relies on are recent frontend features - on an older install the dropdown will be empty or the node silently vanishes from the prompt when you queue (the pack just deletes an unresolvable ref). That last one is the real trap: no error, it's just gone.

    Duplicate group titles are an explicit failure. If two groups share a title, queueing throws an Ambiguous: "<name>" error and stops. The group also needs to actually be a group with a real subgraph - a plain collection of nodes in a colored box without the group IO won't work. And keep in mind this is the deepest feature in the pack: if you're on the latest ComfyUI and comfortable with groups, it's genuinely handy, but it's not the node to test the pack with first.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    ref_nameSTRING

    Outputs (16)

    NameTypeDescription
    out_0*
    out_1*
    out_2*
    out_3*
    out_4*
    out_5*
    out_6*
    out_7*
    out_8*
    out_9*
    out_10*
    out_11*
    out_12*
    out_13*
    out_14*
    out_15*