MCPcopy Create free account
hub / github.com/Lightricks/ComfyUI-LTXVideo / comfy_node

Function comfy_node

nodes_registry.py:63–120  ·  view source on GitHub ↗

Decorator for registering a node class with optional name, description, and status flags. Args: node_class (Type): The class of the node to be registered. name (str, optional): The name of the class. If not provided, the class name will be used. description (str, op

(
    node_class: Optional[Type] = None,
    name: Optional[str] = None,
    description: Optional[str] = None,
    experimental: bool = False,
    deprecated: bool = False,
    skip: bool = False,
)

Source from the content-addressed store, hash-verified

61
62
63def comfy_node(
64 node_class: Optional[Type] = None,
65 name: Optional[str] = None,
66 description: Optional[str] = None,
67 experimental: bool = False,
68 deprecated: bool = False,
69 skip: bool = False,
70) -> Callable:
71 """
72 Decorator for registering a node class with optional name, description, and status flags.
73
74 Args:
75 node_class (Type): The class of the node to be registered.
76 name (str, optional): The name of the class. If not provided, the class name will be used.
77 description (str, optional): The description of the class.
78 If not provided, an auto-formatted description will be used based on the class name.
79 experimental (bool): Flag indicating if the class is experimental. Defaults to False.
80 deprecated (bool): Flag indicating if the class is deprecated. Defaults to False.
81 skip (bool): Flag indicating if the node registration should be skipped. Defaults to False.
82 This is useful for conditionally registering nodes based on certain conditions
83 (e.g. unavailability of certain dependencies).
84
85 Returns:
86 Callable: The decorator function.
87
88 Raises:
89 ValueError: If `node_class` is not a class.
90 """
91
92 def decorator(node_class: Type) -> Type:
93 if skip:
94 return node_class
95
96 if not isinstance(node_class, type):
97 raise ValueError("`node_class` must be a class")
98
99 nonlocal name, description
100 if name is None:
101 name = node_class.__name__
102
103 # Remove possible "Node" suffix from the class name, e.g. "EditImageNode -> EditImage"
104 if name is not None and name.endswith("Node"):
105 name = name[:-4]
106
107 description = _format_description(description, name, experimental, deprecated)
108
109 # For v3 nodes, wrap define_schema to inject the display_name
110 if _is_v3_node(node_class):
111 _wrap_define_schema(node_class, description)
112
113 register_node(node_class, name, description)
114 return node_class
115
116 # If the decorator is used without parentheses
117 if node_class is None:
118 return decorator
119 else:
120 return decorator(node_class)

Callers

nothing calls this directly

Calls 1

decoratorFunction · 0.85

Tested by

no test coverage detected