Comfy-Org / Comfy-Org/ComfyUI

custom node's IS_CHANGED not being executed with kwarg values

Open
#8,828 3 comments 0 reactions 1 assignee Claimed by @yoland68 View on GitHub
bug-cop:taking-a-look Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

When writing a custom node, I would expect that my `IS_CHANGED` method would be passed the values from the connected inputs, as is the case with the business-logic `FUNCTION` function. However, almost all the values passed into `IS_CHANGED` are None.

For example, I created a test custom node to see if I could get any values to appear in IS_CHANGED. The custom node takes a required image, an optional image, and the three hidden values.

The node is hooked up like this:

Image

I would expect the args in `IS_CHANGED` to be `(image tensor, image tensor, string, dict, dict)`.

### Actual Behavior

Instead, the values are `(None, None, "6", {}, None)`

Strangely, `unique_id` gets passed in fine, and `prompt` is an empty dict, while `extra_pnginfo`, which should also be a `dict`, is `None`.

Printing the same string in the `run(...)` function spits out the values I would expect, indicating that despite what the docs say [here](https://docs.comfy.org/custom-nodes/backend/server_overview#is-changed), _"IS_CHANGED is passed the same arguments as the main function defined by FUNCTION"_, this is not the case.

### Steps to Reproduce

I installed comfy from scratch, using the latest version from master.
I create a new custom node called `test_node.py`:
```
class TEST_NODE:

@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image_req": ("IMAGE",),
},
"optional": {
"image_opt": ("IMAGE",),
},
"hidden": {
"unique_id": "UNIQUE_ID",
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO",
}
}

RETURN_TYPES = ("IMAGE",)
FUNCTION = "run"

CATEGORY = "image/Test Nodes"

def run(self, image_req, image_opt=None, unique_id=None, prompt=None, extra_pnginfo=None):
print("run(...) arg types: image_req: {}, image_opt: {} unique_id: {} prompt: {} extra_pnginfo: {}".format(type(image_req), type(image_opt), type(unique_id), type(prompt), type(extra_pnginfo)))
return (image_req,)

@classmethod
def IS_CHANGED(cls, image_req, image_opt=None, unique_id=None, prompt=None, extra_pnginfo=None):
# `print` doesn't seem to work in `IS_CHANGED`, so we use `raise Exception` to log the values.
raise Exception("IS_CHANGED(...) arg types: image_req: {}, image_opt: {} unique_id: {} prompt: {} extra_pnginfo: {}".format(type(image_req), type(image_opt), type(unique_id), type(prompt), type(extra_pnginfo)))

NODE_CLASS_MAPPINGS = {
"Test_Node": TEST_NODE,
}

NODE_DISPLAY_NAME_MAPPINGS = {
"Test_Node": "🔒 Test Node"
}
```

### Debug Logs

Running a workflow with the Test Node spits this out to console:

```powershell
WARNING: IS_CHANGED(...) arg types: image_req: , image_opt: unique_id: prompt: extra_pnginfo:

run(...) arg types: image_req: , image_opt: unique_id: prompt: extra_pnginfo:
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.