ComfyUI/comfy_extras/nodes_v3_test.py
2025-06-05 16:42:51 -07:00

70 lines
3.2 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import torch
from comfy_api.v3.io import (
ComfyNodeV3, SchemaV3, InputBehavior, NumberDisplay,
IntegerInput, MaskInput, ImageInput, ComboInput, CustomInput, StringInput, CustomType,
IntegerOutput, ImageOutput, MultitypedInput,
NodeOutput, Hidden
)
import logging
class V3TestNode(ComfyNodeV3):
def __init__(self):
self.hahajkunless = ";)"
@classmethod
def DEFINE_SCHEMA(cls):
return SchemaV3(
node_id="V3TestNode1",
display_name="V3 Test Node",
description="This is a funky V3 node test.",
category="v3 nodes",
inputs=[
ImageInput("image", display_name="new_image"),
CustomInput("xyz", "XYZ", behavior=InputBehavior.optional),
MaskInput("mask", behavior=InputBehavior.optional),
IntegerInput("some_int", display_name="new_name", min=0, max=127, default=42,
tooltip="My tooltip 😎", display_mode=NumberDisplay.slider),
ComboInput("combo", options=["a", "b", "c"], tooltip="This is a combo input"),
# ComboInput("combo", image_upload=True, image_folder=FolderType.output,
# remote=RemoteOptions(
# route="/internal/files/output",
# refresh_button=True,
# ),
# tooltip="This is a combo input"),
# IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ),
# ComboDynamicInput("mask", behavior=InputBehavior.optional),
# IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider,
# dependent_inputs=[ComboDynamicInput("mask", behavior=InputBehavior.optional)],
# dependent_values=[lambda my_value: IO.STRING if my_value < 5 else IO.NUMBER],
# ),
# ["option1", "option2". "option3"]
# ComboDynamicInput["sdfgjhl", [ComboDynamicOptions("option1", [IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ImageInput(), MaskInput(), String()]),
# CombyDynamicOptons("option2", [])
# ]]
],
outputs=[
IntegerOutput("int_output"),
ImageOutput("img_output", display_name="img🖼", tooltip="This is an image"),
],
hidden=[
],
is_output_node=True,
)
@classmethod
def execute(cls, image: torch.Tensor, some_int: int, combo: str, xyz=None, mask: torch.Tensor=None):
if hasattr(cls, "hahajkunless"):
raise Exception("The 'cls' variable leaked instance state between runs!")
if hasattr(cls, "doohickey"):
raise Exception("The 'cls' variable leaked state on class properties between runs!")
cls.doohickey = "LOLJK"
return NodeOutput(some_int, image)
NODES_LIST: list[ComfyNodeV3] = [
V3TestNode,
]