Skip to main content

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

Project description

yors_comfyui_node_setup

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

PyPI - Version PyPI - License

to setup comfyui custom nodes for developers in development:

  • install requriements automatically for nodes
  • entry - export comfyui node vars automatically

1 - install python package

pip install yors_comfyui_node_setup
# yors_comfyui_node_util

2 - use it in your python code

  • in some comfyui custom nodes project or module

  • code in __init__.py

#
# from ...utils import entry,node_install_requirements # local
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__)

# register_node_list(this_module_all_classes,False,"ymc/as_x_type")
  • or :
from yors_comfyui_node_setup import entry_pre_import,entry_import,get_all_classs_in_sys,node_install_requirements

# install requirements
node_install_requirements(__file__)

# gen __all__
__all__ = entry_pre_import(__name__,__file__)

# import moudle with __all__
entry_import(__name__)

# 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(this_module_all_classes,False,"ymc/as_x_type")

3 - code yours nodes

  • dirs map of your node may be:
.
└─__init__.py
└─nodes.py
  • in any py file (no test in __init__.py)
  • code nodes.py
class AnyType(str):
  """A special class that is always equal in not equal comparisons. Credit to pythongosssss"""

  def __ne__(self, __value: object) -> bool:
    return False

any_type = AnyType("*")


CURRENT_CATEGORY="YMC/LINK" # set the right mouse button menu (custom for your comfyui nodes)
CURRENT_FUNCTION="exec"

class NodeSetItAsImage:
    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": {

            },
            "optional":{
                "a": (any_type),
            },
            # "hidden": {
            #     "unique_id": "UNIQUE_ID",
            #     "extra_pnginfo": "EXTRA_PNGINFO",
            # },
        }

    # INPUT_IS_LIST = True
    RETURN_TYPES = ("IMAGE",)
    RETURN_NAMES = ("image",)

    FUNCTION = CURRENT_FUNCTION
    CATEGORY = CURRENT_CATEGORY
    # set NODE_NAME and NODE_DESC for yors_comfyui_node_setup
    NODE_NAME = "as image"
    NODE_DESC = "set it as image type"
    # OUTPUT_NODE = True
    # OUTPUT_IS_LIST = (True,)
    def exec(self, a=None):
        return (a,)

Author

ymc-github ymc.github@gmail.com

License

MIT

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.6.0.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

yors_comfyui_node_setup-0.6.0-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

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