From a263afbde56267588d486fc0a39478d877e58518 Mon Sep 17 00:00:00 2001
From: "Lex Darlog (DRL)" <3897975+Lex-DRL@users.noreply.github.com>
Date: Sun, 24 Aug 2025 02:29:22 +0500
Subject: [PATCH] `funcs`: importable outside comfy
---
funcs.py | 30 +++++++++++++++++-------------
return_tuples.py | 2 +-
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/funcs.py b/funcs.py
index 8509205..3f071d4 100644
--- a/funcs.py
+++ b/funcs.py
@@ -8,8 +8,6 @@ import typing as _t
from math import sqrt as _sqrt
-from server import PromptServer as _PromptServer
-
from .enums import *
from .return_tuples import *
@@ -17,6 +15,23 @@ from .return_tuples import *
_t_number = _t.Union[int, float]
+try:
+ from server import PromptServer as _PromptServer
+
+ def _show_text_on_node(text: str = None, node_id: str = None):
+ if not text:
+ # TODO: Planned for the future - currently, there's no point removing the text since it's box is shown anyway
+ # An odd workaround since `send_progress_text()` doesn't want to update text when '' passed
+ text = ''
+ # print(f"{unique_id} text: {text!r}")
+
+ # Snatched from: https://github.com/comfyanonymous/ComfyUI/blob/27870ec3c30e56be9707d89a120eb7f0e2836be1/comfy_extras/nodes_images.py#L581-L582
+ _PromptServer.instance.send_progress_text(text, node_id)
+except ImportError:
+ def _show_text_on_node(text: str = None, node_id: str = None):
+ pass
+
+
def aspect_ratios_sorted(aspect_a: float, aspect_b: float, min_clamp: float = 1.0):
"""Return aspect ratio in a standard form: 2 floats, both 1+, in descending order (16:9, not 9:16)."""
aspect_a = float(max(abs(aspect_a), min_clamp))
@@ -93,17 +108,6 @@ def float_width_height_from_area(square_size: _t_number, landscape: bool, aspect
return width_f, height_f
-def _show_text_on_node(text: str = None, unique_id: str = None):
- if not text:
- # TODO: Planned for the future - currently, there's no point removing the text since it's box is shown anyway
- # An odd workaround since `send_progress_text()` doesn't want to update text when '' passed
- text = ''
- # print(f"{unique_id} text: {text!r}")
-
- # Snatched from: https://github.com/comfyanonymous/ComfyUI/blob/27870ec3c30e56be9707d89a120eb7f0e2836be1/comfy_extras/nodes_images.py#L581-L582
- _PromptServer.instance.send_progress_text(text, unique_id)
-
-
def _format_report_square_part(
width_f: float, height_f: _t_number,
width: int, height: int,
diff --git a/return_tuples.py b/return_tuples.py
index 5bfab47..9bd6b7e 100644
--- a/return_tuples.py
+++ b/return_tuples.py
@@ -1,6 +1,6 @@
# encoding: utf-8
"""
-For readability, all nodes in this node pack return NamedTuples instead of regular tuples.
+For readability, the results of all node-functions in this node pack are NamedTuples instead of regular tuples.
"""
import typing as _t