Skip to main content

A python library for setup comfyui custom nodes for developers in development

Project description

A python library for setup comfyui custom nodes for developers in development

File size

Features

  • feat(core): pyio_read_dirs_name - read dirs name in some location
  • feat(core): pyio_read_file_name - read file name in some location
  • feat(core): pyio_read_module_name - read python module name in some location
  • feat(core): get_sys_module - get python module in sys with name
  • feat(core): get_classes_in_module - get class list in python module
  • feat(core): get_module_name_list - get module name list in sys.modules with substring name
  • feat(core): list_ignore_them - list ignore them
  • feat(core): std_stro_name - std name in stro
  • feat(core): std_module_name - std name for module
  • feat(core): import_custom_node_module - import custom node module in some sub location
  • feat(core): is_yors_style_node - check if a node class is yors-style node
  • feat(core): get_node_class_in_sys_modules - get node (yors style) class name in sys modules with substring name
  • feat(core): get_all_classs_in_sys - get all class in sys
  • feat(core): register_node_list - register comfyui node (yors style) through udate node class map and and display name map and more
  • feat(core): use global vars
  • feat(core): use default category in node when custom categoty not passed
  • feat(core): info repeat node when node
  • feat(core): register_node_list_local - not using global vars
  • feat(core): get_node_desc - get yors-style node desc from node class
  • feat(core): get_node_name - get yors-style node name from node class
  • feat(core): get_node_menu_name - get yors-style node menu name from node class
  • feat(core): gen_menu_name - gen yors-style node display name
  • feat(core): import_py_file - import py file in location
  • feat(core): read_py_file_name_list - read py file name list in location
  • feat(core): ignore __init__.py
  • feat(core): read_py_file_name_list_no_suffix - read py file name list in location wihout .py suffix
  • feat(core): ignore __init__.py
  • feat(core): get_module_name_contains_x_in_sys - get all module name with subtring name in sys
  • feat(core): ignore eq x
  • feat(core): get_module_contains_x_name_in_sys - get all module with subtring name in sys
  • feat(core): ignore eq x
  • feat(core): debug_print - print msg if node loading debug status opened
  • feat(core): debug_status - update node loading debug status
  • feat(core): entry_pre_import - make __all__ with name and file location
  • feat(core): entry_import - import module with importlib.import_module and __all__
  • feat(core): entry_post_import - prepare import for comfyui node
  • feat(core): entry - make entry vars for comfyui node
  • feat(core): pyio_install_requirements - install requirements in file location without installed packages checking before installing
  • feat(core): ensure_package - install some python package if not installed
  • feat(core): spio_install_requirements - install some python package in file location if not installed
  • feat(core): node_install_requirements - install requirements in dir and file name
  • feat(core): set_node_class_category_alias - set node category alias through extended class

Usage

pip install yors_comfyui_node_setup

Demo

case 1

  • code your __init__.py
# v1
from yors_comfyui_node_setup import entry,node_install_requirements # global

# install requirements
node_install_requirements(__file__)

# export comfyui node vars
__all__,NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = entry(__name__,__file__)
  • code your nodes . xx.py
# from .conf import CURRENT_CATEGORY,CURRENT_FUNCTION

CURRENT_CATEGORY="ymc/text" # as default category
CURRENT_FUNCTION="exec" 

class TextInput:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": {
                    "text": ("STRING",{"multiline": True,"default": ""}),
                  },
                }
    
    RETURN_TYPES = ("STRING",) 
    CATEGORY = CURRENT_CATEGORY
    FUNCTION = CURRENT_FUNCTION
    # NODE_NAME = "strm input"
    NODE_DESC = "multiline text" # NODE_NAME or NODE_DESC must be set. I prefer use NODE_DESC only.
    INPUT_IS_LIST = False
    OUTPUT_IS_LIST = (False,)

    # must has method named xx bind to FUNCTION
    def exec(self,**kwargs):
        text = kwargs.get("text","")
        return (text,)
    

case 2

  • code your __init__.py
# v2
from yors_comfyui_node_setup import node_install_requirements,entry_pre_import,entry_import,get_all_classs_in_sys,register_node_list_local
from yors_pano_ansi_color import info_status

# 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))
  • code your nodes xx.py

case 3 (recomended)

  • code your __init__.py
# Set the web directory, any .js file in that directory will be loaded by the frontend as a frontend extension
WEB_DIRECTORY = "./web"

INFO_NODE_NAME=True
INSTALL_NODE_WITH_DEFAULT_CATEGORY=False
INFO_RIGHT_MENU=True
INFO_NODE_SETUP_STEP=True
def info_usage_step(msg):
    global INFO_NODE_SETUP_STEP
    if INFO_NODE_SETUP_STEP:
        print(f'[step] {msg}')
# v1
# from yors_comfyui_node_setup import entry,node_install_requirements # global

# info_usage_step("v1 1. install requirements")
# node_install_requirements(__file__)

# # 
# info_usage_step("v1 2. export comfyui node vars")
# __all__,NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = entry(__name__,__file__)

# v2
info_usage_step("v2 1. import node setup utils")
from yors_comfyui_node_setup import node_install_requirements,entry_pre_import,entry_import,get_all_classs_in_sys,register_node_list_local,register_node_list

info_usage_step("v2 1.1 install requirements")
node_install_requirements(__file__)

info_usage_step("v2 1.2 gen __all__")
__all__ = entry_pre_import(__name__,__file__)

info_usage_step("v2 1.3 import moudle with __all__")
entry_import(__name__,__all__)

info_usage_step("v2 1.4 get class after importing moudle with __all__")
this_module_all_classes = get_all_classs_in_sys(__name__)

if INSTALL_NODE_WITH_DEFAULT_CATEGORY:
    info_usage_step("v2 1.5 register node with default category")
    NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES  = register_node_list(this_module_all_classes,INFO_NODE_NAME)

info_usage_step("v2 1.6 addtional register node with custom category")
NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES  = register_node_list_local(this_module_all_classes,INFO_NODE_NAME,"ymc/strm")
# print(NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES)

info_usage_step("v2 1.7 addtional register node with custom category")
if INFO_RIGHT_MENU:
    print("\n".join(NODE_MENU_NAMES))


# docs(core): load web ext
WEB_DIRECTORY = "./web"

# __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
# docs(core): export NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,WEB_DIRECTORY
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
  • code your nodes xx.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yors_comfyui_node_setup-0.11.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yors_comfyui_node_setup-0.11.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file yors_comfyui_node_setup-0.11.0.tar.gz.

File metadata

  • Download URL: yors_comfyui_node_setup-0.11.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.6 Windows/10

File hashes

Hashes for yors_comfyui_node_setup-0.11.0.tar.gz
Algorithm Hash digest
SHA256 5dc3adf38de9a0c61156661aaf87dcd63393facf4f1ffe14ee6c14ecd49e3133
MD5 c6d93e3cf7ec6b1d5c296d6b6ff4d0a6
BLAKE2b-256 abf462a9f37fbf22ae2d69a3acbc8123a5a7ced236a659dc2e505da7de0cd7c7

See more details on using hashes here.

File details

Details for the file yors_comfyui_node_setup-0.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for yors_comfyui_node_setup-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05b9f2b86b6aa552f95225ed8d8e9e4b335afe52c5d88adea89892ceb7f148c3
MD5 5d539526124380c4b6f9374d177c377b
BLAKE2b-256 b5f5ce8cea9aa8c7a163fb6dee13ee2f82e442aab3f210d800422d5f8ad5e4b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page