From beefaf0442417811b4b5c441c954679e79cc64e0 Mon Sep 17 00:00:00 2001 From: Lukas Julian Lambertz Date: Sat, 21 Jun 2025 13:30:13 +0200 Subject: [PATCH] DebugPrint now accept any types --- README.md | 139 +++++++++++++++++--- nodes/__pycache__/utilities.cpython-312.pyc | Bin 2853 -> 3429 bytes nodes/utilities.py | 20 ++- 3 files changed, 134 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 16f8b71..53d3839 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,134 @@ -# DebugPadawans-ComfyUI-Essentials +# DebugPadawan's ComfyUI Essentials -This is a useful collection of various nodes for different types of processing and manipulation in ComfyUI. +A collection of essential custom nodes for ComfyUI that provides useful utilities for text processing, data manipulation, and workflow enhancement. -## 🚀 Installation +## Features -### Step 1: Clone into custom_nodes -Clone this repository directly into your ComfyUI `custom_nodes` directory: +- **Text Processing Nodes**: Split, join, and manipulate text strings +- **Data Utilities**: Convert between different data types +- **Workflow Helpers**: Common operations to streamline your ComfyUI workflows +- **Debug Tools**: Print and inspect values during workflow execution +## Installation + +1. Clone this repository into your ComfyUI `custom_nodes` directory: ```bash -cd /path/to/your/ComfyUI/custom_nodes +cd ComfyUI/custom_nodes git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git ``` -### Step 2: Install requirements -Navigate into the plugin folder and install the required dependencies: +2. Restart ComfyUI -```bash -cd DebugPadawans-ComfyUI-Essentials -pip install -r requirements.txt -``` +## Available Nodes -### Step 3: Start or Restart ComfyUI -Make sure ComfyUI is running. If not, start or restart it now. The nodes from this plugin will then appear in the "DebugPadawan" category inside ComfyUI. +### Text Processing -## 🔧 Requirements +#### Text Splitter +**Category**: DebugPadawan/Text -- ComfyUI -- Python 3.7 or higher -- Packages listed in `requirements.txt` +Splits a text string at a specified delimiter and returns a list of strings. + +**Inputs:** +- `text` (String): The text to split (supports multiline input) +- `delimiter` (String): The character(s) to split by (default: ",") +- `strip_whitespace` (Boolean, optional): Remove leading/trailing whitespace from each element (default: True) +- `remove_empty` (Boolean, optional): Remove empty strings from the result (default: True) + +**Outputs:** +- `text_list` (List): The split list of strings +- `count` (Integer): Number of elements in the list + +**Example:** +- Input: `"apple, banana, orange"` +- Delimiter: `","` +- Output: `["apple", "banana", "orange"]` and `3` + +Process CSV-like data, split tag lists, separate coordinates or parameters, create filename lists, and parse prompt components. --- -**Author:** DebugPadawan -**Created:** 2025-06-21 \ No newline at end of file +#### Text Joiner +**Category**: DebugPadawan/Text + +Combines a list of strings into a single text string with a customizable delimiter. + +**Inputs:** +- `text_list` (List): List of strings to join +- `delimiter` (String): Character(s) to join with (default: ", ") +- `prefix` (String, optional): Text to add at the beginning +- `suffix` (String, optional): Text to add at the end + +**Outputs:** +- `joined_text` (String): The combined text string + +**Example:** +- Input: `["red", "green", "blue"]` +- Delimiter: `" | "` +- Prefix: `"Colors: "` +- Suffix: `" - end"` +- Output: `"Colors: red | green | blue - end"` + +Combine prompt parts, convert lists to readable text, create tags for metadata, build filenames from components, and format output strings. + +--- + +### Debug Tools + +#### Debug Print +**Category**: DebugPadawan/Debug + +Prints values to the console without interrupting the workflow. Perfect for debugging and monitoring data values during execution. Accepts any input type including strings, integers, floats, booleans, lists, dictionaries, and complex objects. + +**Inputs:** +- `value` (*): Any value to print to console (supports all data types) +- `label` (String, optional): Label for the debug output (default: "Debug") + +**Outputs:** +- `passthrough` (*): The same value passed through unchanged + +**Console Output:** +``` +[MyLabel] list: ['Element1', 'Element2', 'Element3'] +[Debug] str: Hello World +[Checkpoint] int: 42 +[Data Flow] dict: {'key': 'value', 'count': 5} +[Boolean Test] bool: True +[Float Value] float: 3.14159 +``` + +Monitor values during workflow execution, debug complex workflows, verify data types and contents, set workflow checkpoints, and troubleshoot unexpected results. Use descriptive labels and remember that the node doesn't interrupt data flow. + +--- + +### Utility Nodes + +#### List Info +**Category**: DebugPadawan/Utilities + +Analyzes a list and returns useful information about it. + +**Inputs:** +- `input_list` (List): The list to analyze + +**Outputs:** +- `count` (Integer): Number of elements +- `first_item` (String): First element (as string) +- `last_item` (String): Last element (as string) + +Validate list processing results, get quick list statistics, check if lists are empty, and extract boundary values. + +#### Conditional String +**Category**: DebugPadawan/Logic + +Returns one of two strings based on a boolean condition. + +**Inputs:** +- `condition` (Boolean): The condition to evaluate +- `true_string` (String): String to return if True (default: "True") +- `false_string` (String): String to return if False (default: "False") + +**Outputs:** +- `result` (String): The selected string + +Conditional prompt modification, dynamic filename generation, workflow branching based on conditions, and status message generation. + diff --git a/nodes/__pycache__/utilities.cpython-312.pyc b/nodes/__pycache__/utilities.cpython-312.pyc index 18bfdd63fcda005e8c18575e0dcfc1627021a1a3..4dae3ecbe4322ddf67ea0a0fe7d71740d64e55af 100644 GIT binary patch delta 1445 zcmZWoT}T{P6u$S)otgb{-P%N5|C+5vnu#^0tc5m;Xuy~R*_67NuoR~2&TONsyK-l? zbi)=G>cc)N6Hw4XN+~22qL9}d%o#h`@?$&fot&OvvweXfC;7oGgK{Neq%EjLZ;&t`UQobXW4frx_zA zGo)SGI7?m>hbVcMHGJIjDd1CI`DC+`o3atuVQIw(8X?b8%VDi$V`X-uFSy$4)ip_) zLTzSHQ-ZoY#|>$Xr{yx&WLKRklvCvu(~as4OV>ZoK3~Vpzk$In zy}Yrvckc?AFb8VG?k@v)U!*y$npSYINSY9gN?@6v_XwAl}8R!wCHd_*}#Y z!c~O#5XKSCaFIYC!WeMT;T#4v#e1s>M-63q1AbZ@sQ+*;poN@>gi{Jl&;2)>8yH_M z8l}8BA+AFV3g5a5a3oPmkC{Yyy@k>CTDDGLI}Q-FwU+%VUzJYz5RDxZfYVQ$zd}PC Gd-xZeZ7Y5N delta 872 zcmZ9K?@JUx7{_O3XZLRJJkL5kul%)o>a|)Kq>-U!p?H>@kynHSq0U|&Txzp-kRo_5 zB7A8L;e{2w@r6hb^fLMjdgBXU$kK}-dao$?vgX;nf*RP*KJ(1?d7gP5=Ev#H=*pK+ zD1hYp`Qq+uo3y^e=Fg&K<8VkC>xiLAM9>Ig_$gv!n|P;_*!3yWNB{bWg)PF=*JM&* z8uPgpUG$s!Qh(r1KAX$t7md_Bvz~AEi_bn?ydHe@vngP#OXt;AAv$eJ!Z zyaoF649o{^Y%{10i6T0RBE51AueGh!mPo0ml-Q|k+4aZws%loBtcH2D6s1heb@?}g zj$ddbE`DiI91&4pcOw+xVE_od!f*=?(8R1S(b!ZR+l$1DW8cE{#pGT%UQ8a*3N_{h zDB`{Epdlp1vM=BD@$s?YYbg#BN;@>o3l7!g!&!960O-_YFh zH6IuCb=(1Blkz(G8z<)D bool: + return False + +any = AnyType("*") + class DebugPrint: """ Node for debugging - prints values to console @@ -12,8 +19,7 @@ class DebugPrint: def INPUT_TYPES(cls): return { "required": { - # Specify common types explicitly instead of using wildcard - "value": ("STRING", {"forceInput": True}), + "value": (any, {"forceInput": True}), }, "optional": { "label": ("STRING", { @@ -23,8 +29,8 @@ class DebugPrint: } } - # Match the input type exactly - RETURN_TYPES = ("STRING",) + # Use wildcard for output type to pass through any type + RETURN_TYPES = ("*",) RETURN_NAMES = ("passthrough",) FUNCTION = "debug_print" @@ -41,7 +47,11 @@ class DebugPrint: Returns: The same value (passthrough) """ - print(f"[{label}] {value}") + # Convert the value to a string for debugging purposes + debug_value = str(value) if not isinstance(value, str) else value + print(f"[{label}] {type(value).__name__}: {debug_value}") + + # Return the original value unchanged return (value,)