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

Why

  • setup your comfyui nodes easily
  • install requirements automatically (easy and optional)
  • set your comfyui nodes to right mouse menu as your likes (easy and optional)

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

# ucase 1.0:
# 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__)

# ucase 2.0:
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 automatically
# if requrements.txt in here and deps in it not installed
node_install_requirements(__file__)

# gen __all__ and import moudle with __all__
# with this you can wirte your nodes in any py file in the same diretory
__all__ = entry_pre_import(__name__,__file__)
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
# it will not register the same node if you/he/she register the same nodes in other custom repo. (save disk space)
NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES  = register_node_list_local(this_module_all_classes,False)

# addtional register node with custom category (no test)
# NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES  = register_node_list_local(this_module_all_classes,True,"YMC/as_x_type")
print("\n".join(NODE_MENU_NAMES))

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
# 1. define yors comfyui nodes here
# ...
# ucase 1.0:
# 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,)


# ucase 1.1:
from yors_comfyui_node_as_x_type import * # import all yors comfyui nodes from it

# ucase 1.2:
# from yors_comfyui_node_as_x_type import NodeSetItAsImage # import some yors comfyui nodes from it


# 2. reset yors comfyui nodes category (it will be used set rmb in yors_comfyui_node_setup)
# from yors_comfyui_node_reset_rmb import reset_rmb
# reset_rmb(__name__,"YMC/as_x_type") // danger!

# 3. set nodes category alias
# to set the right mouse menu as your likes.

# set nodes defined in yors_comfyui_node_as_x_type under the category YMC/as_x_type
import yors_comfyui_node_as_x_type as base
from yors_comfyui_node_setup import get_sys_module,set_node_class_category_alias
this_py_module = get_sys_module(__name__)
set_node_class_category_alias(base,this_py_module,"YMC/as_x_type",True)

the dirs of your comfyui nodes repo

.
│  .gitignore
│  LICENSE
│  nodes.py
│  requirements.txt
│  __init__.py
└─link # some nodes to link nodes
    __init__.py
    xx.py
    ...
└─utils # some nodes for util process
    __init__.py
    xx.py
    ...
└─image # some nodes for image process
    __init__.py
    xx.py
    ...

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.9.0.tar.gz (9.7 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.9.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yors_comfyui_node_setup-0.9.0.tar.gz
  • Upload date:
  • Size: 9.7 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.9.0.tar.gz
Algorithm Hash digest
SHA256 a221e3b1631cf757ab39cf6ca39a609f22e0d1524c0ab9529bb48ac3f29c3fcf
MD5 2909fee31c829439ac1851dac437a88a
BLAKE2b-256 1805b3a57cb28681f04c5948d442032f2a0d912d08fa67afc69f32c345b2325c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yors_comfyui_node_setup-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 371932a86d7209ef315dd1e4e9e4117bb05a2ec0b1d2e4171e550d27fd43683d
MD5 df1a6b200774cc99379de2c29061f30a
BLAKE2b-256 15075ce3f872a150c789530c993849b4625071237f209a53ed8d88fe3d547864

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