diff --git a/__init__.py b/__init__.py index 4f36ca3..b061201 100644 --- a/__init__.py +++ b/__init__.py @@ -5,9 +5,7 @@ from .adjustment import ( SuperLevelsNormalize, SuperWhiteBalanceCAT, ) -from .debug import ( - SuperLatentStats, -) +from .debug import SuperLatentStats, SuperStopExecution from .image import ImageMaskCrop, RestoreMaskCrop from .qol import ( FaceBBoxToMask, @@ -40,6 +38,7 @@ NODE_CLASS_MAPPINGS = { "GetCommonAspectRatio": GetCommonAspectRatio, "SetReserveVRAM": SetReserveVRAM, "SuperLatentStats": SuperLatentStats, + "User Error": SuperStopExecution, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -63,6 +62,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "GetCommonAspectRatio": "🐧 Get Aspect Ratio", "SetReserveVRAM": "🐧 Set Reserve VRAM", "SuperLatentStats": "🐧 Latent Stats", + "User Error": "🐧 Show Error Message", } print("\033[34m[SuperNodes]\033[0m Classes initialized.") diff --git a/debug.py b/debug.py index 0334358..d30fcbf 100644 --- a/debug.py +++ b/debug.py @@ -175,8 +175,39 @@ class SuperLatentStats: RETURN_TYPES = ("STRING",) FUNCTION = "run" - CATEGORY = "SuperNodes/adjustment" + CATEGORY = "SuperNodes/debug" def run(self, latent, label="latent", top_k=12): x = _get_samples(latent) return (_latent_stats_string(x, name=str(label), top_k=int(top_k)),) + + +class SuperStopExecution: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + # "multiline": False ensures a single-line text input widget + "message": ( + "STRING", + { + "multiline": False, + "default": "Execution stopped manually.", + }, + ), + }, + "optional": { + # This wildcard input allows you to connect any node (Image, Latent, etc.) + # to this node to force the execution flow to reach here. + "trigger": ("*", {}), + }, + } + + RETURN_TYPES = () + FUNCTION = "halt_execution" + OUTPUT_NODE = True + CATEGORY = "SuperNodes/debug" + + def halt_execution(self, message, trigger=None): + safe_message = str(message) + raise Exception(f"⛔ {safe_message}") diff --git a/pyproject.toml b/pyproject.toml index 0c6931a..ec620ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-supernodes" description = "A miscellaneous node pack of custom implementations needed for workflows released by my SuperComfy YouTube channel." -version = "0.1.9" +version = "0.2.0" license = { file = "LICENSE" } [project.urls]