From 8b399da4c3e720904ae1bfbcace8e06795be1741 Mon Sep 17 00:00:00 2001 From: yemiancheng Date: Tue, 3 Jun 2025 20:54:33 +0800 Subject: [PATCH] build(core): use node setup helper --- __init__.py | 32 ++++++++++++++++++++++++++++++-- conf.py | 2 ++ node_demo.py | 20 ++++++++++++++++++++ nodes.py | 1 + 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 conf.py create mode 100644 node_demo.py diff --git a/__init__.py b/__init__.py index d721463..418dba1 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,31 @@ -from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS +# v1 +# from yors_comfyui_node_setup import entry,node_install_requirements # global -__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file +# # install requirements +# node_install_requirements(__file__) + +# # export comfyui node vars +# __all__,NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = entry(__name__,__file__) + +# v2 +from yors_comfyui_node_setup import node_install_requirements,entry_pre_import,entry_import,get_all_classs_in_sys,register_node_list_local + +# install requirements +node_install_requirements(__file__) + +# gen __all__ +__all__ = entry_pre_import(__name__,__file__) + +# import moudle with __all__ +entry_import(__name__,__all__) + +# get class after importing moudle with __all__ +this_module_all_classes = get_all_classs_in_sys(__name__) + +# register node with default category +# NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = register_node_list(this_module_all_classes,False) + +# addtional register node with custom category +NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = register_node_list_local(this_module_all_classes,True,"ymc/suite") +# print(NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES) +print("\n".join(NODE_MENU_NAMES)) \ No newline at end of file diff --git a/conf.py b/conf.py new file mode 100644 index 0000000..15897b3 --- /dev/null +++ b/conf.py @@ -0,0 +1,2 @@ +CURRENT_CATEGORY="ymc/suite" +CURRENT_FUNCTION="exec" \ No newline at end of file diff --git a/node_demo.py b/node_demo.py new file mode 100644 index 0000000..8816ef7 --- /dev/null +++ b/node_demo.py @@ -0,0 +1,20 @@ +from .conf import CURRENT_CATEGORY,CURRENT_FUNCTION +class TextInput: + @classmethod + def INPUT_TYPES(s): + return {"required": { + "text": ("STRING",{"multiline": True,"default": ""}), + }, + } + + RETURN_TYPES = ("STRING",) + CATEGORY = CURRENT_CATEGORY + FUNCTION = CURRENT_FUNCTION + NODE_DESC = "text - input with multiline input" + INPUT_IS_LIST = False + OUTPUT_IS_LIST = (False,) + + def exec(self,text): + + return (text,) + \ No newline at end of file diff --git a/nodes.py b/nodes.py index 8e0d993..4210796 100644 --- a/nodes.py +++ b/nodes.py @@ -33,6 +33,7 @@ import time # import torch # from tqdm import tqdm +# define manifest about this project in dict MANIFEST = { "name": "ymc node suite", "version": (1,0,0),