vivax3794 / ComfyUI-Sub-Nodes

Finally sub nodes in comfy!
132 stars 5 forks source link

Save function not getting patched #1

Closed 807502278 closed 2 months ago

807502278 commented 3 months ago

Finally, the long-awaited feature has arrived : )

My comfyui is the latest version, and I have created a child node workflow: image

But there seems to be an issue with the VIV_Subgraph node: image image

vivax3794 commented 3 months ago

huh interesting, it should be loading the input/outputs for the workflow (tbh I expect the node to get like that when you have no subnodes ... something I need to fix, but you clearly have one .... hmmm).

are there any errors in the console (browser and/or comfy)? would also be helpful if you could attach the subnode file so I can see if I can replicate it locally.

RitchieTheBrit commented 3 months ago

Same issue. These errors log when I tried to load the node...

[Impact Pack] Wildcards loading done.
Error handling request
Traceback (most recent call last):
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\python_embeded\Lib\site-packages\aiohttp\web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\python_embeded\Lib\site-packages\aiohttp\web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\python_embeded\Lib\site-packages\aiohttp\web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\ComfyUI\server.py", line 42, in cache_control
    response: web.Response = await handler(request)
                             ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\ComfyUI\server.py", line 54, in cors_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\ComfyUI\custom_nodes\ComfyUI-Sub-Nodes\__init__.py", line 230, in get_input_outputs
    "outputs": get_outputs(workflow),
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AI_Frameworks\ComfyUI_Windows_portable\ComfyUI\custom_nodes\ComfyUI-Sub-Nodes\__init__.py", line 54, in get_outputs
    if node["class_type"] == "VIV_Subgraph_Outputs":
       ~~~~^^^^^^^^^^^^^^
TypeError: 'int' object is not subscriptable

Subnode 'Load Checkpoint and Set CLIP Layer.json'...

{
  "last_node_id": 3,
  "last_link_id": 4,
  "nodes": [
    {
      "id": 1,
      "type": "CheckpointLoaderSimple",
      "pos": [
        100,
        130
      ],
      "size": [
        300,
        100
      ],
      "flags": {},
      "order": 0,
      "mode": 0,
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            2
          ],
          "shape": 3,
          "label": "MODEL",
          "slot_index": 0
        },
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            1
          ],
          "shape": 3,
          "label": "CLIP",
          "slot_index": 1
        },
        {
          "name": "VAE",
          "type": "VAE",
          "links": [
            4
          ],
          "shape": 3,
          "label": "VAE",
          "slot_index": 2
        }
      ],
      "properties": {
        "Node name for S&R": "CheckpointLoaderSimple"
      },
      "widgets_values": [
        "sd_xl_base_1.0.safetensors"
      ]
    },
    {
      "id": 3,
      "type": "VIV_Subgraph_Outputs",
      "pos": [
        800,
        130
      ],
      "size": [
        190,
        100
      ],
      "flags": {},
      "order": 2,
      "mode": 0,
      "inputs": [
        {
          "name": "MODEL.MODEL.52",
          "type": "MODEL",
          "link": 2
        },
        {
          "name": "CLIP.CLIP.34",
          "type": "CLIP",
          "link": 3
        },
        {
          "name": "VAE.VAE.36",
          "type": "VAE",
          "link": 4
        },
        {
          "name": "*",
          "type": "*",
          "link": null
        }
      ],
      "properties": {
        "Node name for S&R": "VIV_Subgraph_Outputs"
      }
    },
    {
      "id": 2,
      "type": "CLIPSetLastLayer",
      "pos": [
        450,
        240
      ],
      "size": [
        300,
        60
      ],
      "flags": {},
      "order": 1,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 1,
          "label": "clip"
        }
      ],
      "outputs": [
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            3
          ],
          "shape": 3,
          "label": "CLIP",
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPSetLastLayer"
      },
      "widgets_values": [
        -1
      ]
    }
  ],
  "links": [
    [
      1,
      1,
      1,
      2,
      0,
      "CLIP"
    ],
    [
      2,
      1,
      0,
      3,
      0,
      "*"
    ],
    [
      3,
      2,
      0,
      3,
      1,
      "*"
    ],
    [
      4,
      1,
      2,
      3,
      2,
      "*"
    ]
  ],
  "groups": [],
  "config": {},
  "extra": {
    "ds": {
      "scale": 0.9090909090909091,
      "offset": [
        367.68237007966115,
        255.26699932019432
      ]
    },
    "groupNodes": {}
  },
  "version": 0.4
}
vivax3794 commented 3 months ago

Well I do see the issue with the workflow file, it should contain some extra data injected by these nodes on save. So the root cause of this is that for some reason the saving function isnt being patched correctly for you for some reason. Are you saving in any non standard way or using any other custom nodes that might mess with exporting the workflow? If you could provide the logs from the browser when you are saving it that might help narrow down the issue, as well as your version of comfy and what browse you use.

(as a side node I should detect this case and provide a helpful error as it is what would happen if you tried to use a workflow saved before you installed the nodes as a subnode, I will put that on the to do list)

807502278 commented 2 months ago

I don't know why, it's inexplicably good again, maybe it's because there's nothing in the subnodes folder when it starts? image

807502278 commented 2 months ago

It seems that there will be no problem as long as there is a json file in the subnodes folder during startup.