diff --git a/.github/workflows/publish_action.yml b/.github/workflows/publish_action.yml new file mode 100644 index 0000000..d89ef1a --- /dev/null +++ b/.github/workflows/publish_action.yml @@ -0,0 +1,20 @@ +name: Publish to Comfy registry +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "pyproject.toml" + +jobs: + publish-node: + name: Publish Custom Node to registry + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Publish Custom Node + uses: Comfy-Org/publish-node-action@main + with: + personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} \ No newline at end of file diff --git a/ArchiGraphLogo.png b/ArchiGraphLogo.png new file mode 100644 index 0000000..26dca68 Binary files /dev/null and b/ArchiGraphLogo.png differ diff --git a/README.md b/README.md index a925cc8..bac9393 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # ComfyUI-ArchiGraph -Implementation of architectural related graph algorithm in ComfyUI. + +
+ +
+ +**ComfyUI-ArchiGraph** is an implementation of architectural related graph algorithm in ComfyUI. + +## 🎈 Introduction + + +## 🚀 Installation +Clone the repo into the **custom_nodes** directory and install the requirements: +```shell +#1. Clone the repo +git clone https://github.com/vincentfs/ComfyUI-ArchiGraph +#2. Install the requirements +Double-click install.bat to install the required dependencies +``` + +## 📜 Credits + +## 💗 SponsorShip + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..570722e --- /dev/null +++ b/__init__.py @@ -0,0 +1,6 @@ +WEB_DIRECTORY = "./js/v1" + +NODE_CLASS_MAPPINGS = {} +NODE_DISPLAY_NAME_MAPPINGS = {} + +__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] \ No newline at end of file diff --git a/example_node.py.example b/example_node.py.example new file mode 100644 index 0000000..29ab2aa --- /dev/null +++ b/example_node.py.example @@ -0,0 +1,155 @@ +class Example: + """ + A example node + + Class methods + ------------- + INPUT_TYPES (dict): + Tell the main program input parameters of nodes. + IS_CHANGED: + optional method to control when the node is re executed. + + Attributes + ---------- + RETURN_TYPES (`tuple`): + The type of each element in the output tuple. + RETURN_NAMES (`tuple`): + Optional: The name of each output in the output tuple. + FUNCTION (`str`): + The name of the entry-point method. For example, if `FUNCTION = "execute"` then it will run Example().execute() + OUTPUT_NODE ([`bool`]): + If this node is an output node that outputs a result/image from the graph. The SaveImage node is an example. + The backend iterates on these output nodes and tries to execute all their parents if their parent graph is properly connected. + Assumed to be False if not present. + CATEGORY (`str`): + The category the node should appear in the UI. + DEPRECATED (`bool`): + Indicates whether the node is deprecated. Deprecated nodes are hidden by default in the UI, but remain + functional in existing workflows that use them. + EXPERIMENTAL (`bool`): + Indicates whether the node is experimental. Experimental nodes are marked as such in the UI and may be subject to + significant changes or removal in future versions. Use with caution in production workflows. + execute(s) -> tuple || None: + The entry point method. The name of this method must be the same as the value of property `FUNCTION`. + For example, if `FUNCTION = "execute"` then this method's name must be `execute`, if `FUNCTION = "foo"` then it must be `foo`. + """ + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + """ + Return a dictionary which contains config for all input fields. + Some types (string): "MODEL", "VAE", "CLIP", "CONDITIONING", "LATENT", "IMAGE", "INT", "STRING", "FLOAT". + Input types "INT", "STRING" or "FLOAT" are special values for fields on the node. + The type can be a list for selection. + + Returns: `dict`: + - Key input_fields_group (`string`): Can be either required, hidden or optional. A node class must have property `required` + - Value input_fields (`dict`): Contains input fields config: + * Key field_name (`string`): Name of a entry-point method's argument + * Value field_config (`tuple`): + + First value is a string indicate the type of field or a list for selection. + + Second value is a config for type "INT", "STRING" or "FLOAT". + """ + return { + "required": { + "image": ("IMAGE",), + "int_field": ("INT", { + "default": 0, + "min": 0, #Minimum value + "max": 4096, #Maximum value + "step": 64, #Slider's step + "display": "number", # Cosmetic only: display as "number" or "slider" + "lazy": True # Will only be evaluated if check_lazy_status requires it + }), + "float_field": ("FLOAT", { + "default": 1.0, + "min": 0.0, + "max": 10.0, + "step": 0.01, + "round": 0.001, #The value representing the precision to round to, will be set to the step value by default. Can be set to False to disable rounding. + "display": "number", + "lazy": True + }), + "print_to_screen": (["enable", "disable"],), + "string_field": ("STRING", { + "multiline": False, #True if you want the field to look like the one on the ClipTextEncode node + "default": "Hello World!", + "lazy": True + }), + }, + } + + RETURN_TYPES = ("IMAGE",) + #RETURN_NAMES = ("image_output_name",) + + FUNCTION = "test" + + #OUTPUT_NODE = False + + CATEGORY = "Example" + + def check_lazy_status(self, image, string_field, int_field, float_field, print_to_screen): + """ + Return a list of input names that need to be evaluated. + + This function will be called if there are any lazy inputs which have not yet been + evaluated. As long as you return at least one field which has not yet been evaluated + (and more exist), this function will be called again once the value of the requested + field is available. + + Any evaluated inputs will be passed as arguments to this function. Any unevaluated + inputs will have the value None. + """ + if print_to_screen == "enable": + return ["int_field", "float_field", "string_field"] + else: + return [] + + def test(self, image, string_field, int_field, float_field, print_to_screen): + if print_to_screen == "enable": + print(f"""Your input contains: + string_field aka input text: {string_field} + int_field: {int_field} + float_field: {float_field} + """) + #do some processing on the image, in this example I just invert it + image = 1.0 - image + return (image,) + + """ + The node will always be re executed if any of the inputs change but + this method can be used to force the node to execute again even when the inputs don't change. + You can make this node return a number or a string. This value will be compared to the one returned the last time the node was + executed, if it is different the node will be executed again. + This method is used in the core repo for the LoadImage node where they return the image hash as a string, if the image hash + changes between executions the LoadImage node is executed again. + """ + #@classmethod + #def IS_CHANGED(s, image, string_field, int_field, float_field, print_to_screen): + # return "" + +# Set the web directory, any .js file in that directory will be loaded by the frontend as a frontend extension +# WEB_DIRECTORY = "./somejs" + + +# Add custom API routes, using router +from aiohttp import web +from server import PromptServer + +@PromptServer.instance.routes.get("/hello") +async def get_hello(request): + return web.json_response("hello") + + +# A dictionary that contains all nodes you want to export with their names +# NOTE: names should be globally unique +NODE_CLASS_MAPPINGS = { + "Example": Example +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "Example": "Example Node" +} diff --git a/install.bat b/install.bat new file mode 100644 index 0000000..ab16553 --- /dev/null +++ b/install.bat @@ -0,0 +1,26 @@ +@echo off + +set "requirements_txt=%~dp0\requirements.txt" +set "requirements_repair_txt=%~dp0\repair_dependency_list.txt" +set "python_exec=..\..\..\python_embeded\python.exe" +set "aki_python_exec=..\..\python\python.exe" + +echo Installing ArchiGraph Requirements... + +if exist "%python_exec%" ( + echo Installing with ComfyUI Portable + "%python_exec%" -s -m pip install -r "%requirements_txt%" +)^ +else if exist "%aki_python_exec%" ( + echo Installing with ComfyUI Aki + "%aki_python_exec%" -s -m pip install -r "%requirements_txt%" + for /f "delims=" %%i in (%requirements_repair_txt%) do ( + %aki_python_exec% -s -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple "%%i" + ) +)^ +else ( + echo Installing with system Python + pip install -r "%requirements_txt%" +) + +pause \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..5c7fb05 --- /dev/null +++ b/install.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +requirements_txt="$(dirname "$0")/requirements.txt" +requirements_repair_txt="$(dirname "$0")/repair_dependency_list.txt" +python_exec="../../../python_embeded/python.exe" +aki_python_exec="../../python/python.exe" + +echo "Installing ArchiGraph Requirements..." + +if [ -f "$python_exec" ]; then + echo "Installing with ComfyUI Portable" + "$python_exec" -s -m pip install -r "$requirements_txt" +elif [ -f "$aki_python_exec" ]; then + echo "Installing with ComfyUI Aki" + "$aki_python_exec" -s -m pip install -r "$requirements_txt" + while IFS= read -r line; do + "$aki_python_exec" -s -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple "$line" + done < "$requirements_repair_txt" +else + echo "Installing with system Python" + pip install -r "$requirements_txt" +fi + +read -p "Press any key to continue..." \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5403bac --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[project] +name = "archigraph" +description = "Implementation of architectural related graph algorithm in ComfyUI." +version = 0.0.1" +license = {file = "LICENSE"} + +[project.urls] +Repository = "https://github.com/vincentfs/ComfyUI-ArchiGraph" +# Used by Comfy Registry https://comfyregistry.org + +[tool.comfy] +PublisherId = "vincentfs" +DisplayName = "ComfyUI-ArchiGraph" +Icon = "" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29