ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Fix validation for generic type

Open jn-jairo opened this issue 2 years ago • 2 comments

The litegraph already accepts the generic type * this PR makes the backend validation accepts it too.

Generic types are useful for custom nodes for things like math and item selection and more, below is an illustrative example:

image

This example generates images with random sizes at each generation and compose a side by side image (more useful with horizontal tiling generation but I didn't want to over complicate this example).

The Select Item node accepts the type * and outputs the type * and select one item using the index input, that in this example is connected to a random value, this node uses a % operation to ensure the index is not out of boundary.

The Math Operation node perform math operations with INT and FLOAT on the same node.

The generic type allows a wide range of dynamic nodes making it possible to create very useful nodes without duplication for different types.

jn-jairo avatar Sep 21 '23 07:09 jn-jairo

Very useful, please merge

BeatBroccoli avatar Jul 08 '24 11:07 BeatBroccoli

Very useful, please merge

This can already be done with AnyType from pythongosssss that we all already use. Most likely why it was never incorporated as this is almost a 10 month old PR

i.e.

# wildcard trick is 100% stolen from pythongossss's
class AnyType(str):
    def __ne__(self, __value: object) -> bool:
        return False

JOV_TYPE_ANY = AnyType("*")

Also, you should make sure this works with PR 26666.

Amorano avatar Jul 08 '24 14:07 Amorano

frontend is replaced by https://github.com/Comfy-Org/ComfyUI_frontend now

mcmonkey4eva avatar Sep 16 '24 04:09 mcmonkey4eva

Let's be honest, no one cared about this PR in this repo, and no one will care about it if I redo the PR in the other repo, so I won't waste my time.

jn-jairo avatar Sep 25 '24 17:09 jn-jairo

see reply at https://github.com/comfyanonymous/ComfyUI/pull/2015#issuecomment-2376050796

mcmonkey4eva avatar Sep 26 '24 06:09 mcmonkey4eva