Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
992ace7c38 |
@@ -12,6 +12,7 @@ from comfy.cli_args import args
|
||||
# Default server capabilities
|
||||
SERVER_FEATURE_FLAGS: dict[str, Any] = {
|
||||
"supports_preview_metadata": True,
|
||||
"supports_progress_text_metadata": True,
|
||||
"max_upload_size": args.max_upload_size * 1024 * 1024, # Convert MB to bytes
|
||||
"extension": {"manager": {"supports_v4": True}},
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ from pydantic import BaseModel
|
||||
|
||||
from comfy import utils
|
||||
from comfy_api.latest import IO
|
||||
from comfy_execution.utils import get_executing_context
|
||||
from server import PromptServer
|
||||
|
||||
from . import request_logger
|
||||
@@ -436,7 +437,9 @@ def _display_text(
|
||||
if text is not None:
|
||||
display_lines.append(text)
|
||||
if display_lines:
|
||||
PromptServer.instance.send_progress_text("\n".join(display_lines), get_node_id(node_cls))
|
||||
ctx = get_executing_context()
|
||||
prompt_id = ctx.prompt_id if ctx is not None else None
|
||||
PromptServer.instance.send_progress_text("\n".join(display_lines), get_node_id(node_cls), prompt_id=prompt_id)
|
||||
|
||||
|
||||
def _display_time_progress(
|
||||
|
||||
@@ -523,7 +523,10 @@ class GetImageSize(IO.ComfyNode):
|
||||
|
||||
# Send progress text to display size on the node
|
||||
if cls.hidden.unique_id:
|
||||
PromptServer.instance.send_progress_text(f"width: {width}, height: {height}\n batch size: {batch_size}", cls.hidden.unique_id)
|
||||
from comfy_execution.utils import get_executing_context
|
||||
ctx = get_executing_context()
|
||||
prompt_id = ctx.prompt_id if ctx is not None else None
|
||||
PromptServer.instance.send_progress_text(f"width: {width}, height: {height}\n batch size: {batch_size}", cls.hidden.unique_id, prompt_id=prompt_id)
|
||||
|
||||
return IO.NodeOutput(width, height, batch_size)
|
||||
|
||||
|
||||
@@ -1224,13 +1224,30 @@ class PromptServer():
|
||||
return json_data
|
||||
|
||||
def send_progress_text(
|
||||
self, text: Union[bytes, bytearray, str], node_id: str, sid=None
|
||||
self, text: Union[bytes, bytearray, str], node_id: str, prompt_id: Optional[str] = None, sid=None
|
||||
):
|
||||
if isinstance(text, str):
|
||||
text = text.encode("utf-8")
|
||||
node_id_bytes = str(node_id).encode("utf-8")
|
||||
|
||||
# Pack the node_id length as a 4-byte unsigned integer, followed by the node_id bytes
|
||||
message = struct.pack(">I", len(node_id_bytes)) + node_id_bytes + text
|
||||
# When prompt_id is provided and client supports the new format,
|
||||
# prepend prompt_id as a length-prefixed field before node_id
|
||||
target_sid = sid if sid is not None else self.client_id
|
||||
if prompt_id and feature_flags.supports_feature(
|
||||
self.sockets_metadata, target_sid, "supports_progress_text_metadata"
|
||||
):
|
||||
prompt_id_bytes = prompt_id.encode("utf-8")
|
||||
# Pack prompt_id length as a 4-byte unsigned integer, followed by prompt_id bytes,
|
||||
# then node_id length as a 4-byte unsigned integer, followed by node_id bytes, then text
|
||||
message = (
|
||||
struct.pack(">I", len(prompt_id_bytes))
|
||||
+ prompt_id_bytes
|
||||
+ struct.pack(">I", len(node_id_bytes))
|
||||
+ node_id_bytes
|
||||
+ text
|
||||
)
|
||||
else:
|
||||
# Pack the node_id length as a 4-byte unsigned integer, followed by the node_id bytes
|
||||
message = struct.pack(">I", len(node_id_bytes)) + node_id_bytes + text
|
||||
|
||||
self.send_sync(BinaryEventTypes.TEXT, message, sid)
|
||||
|
||||
Reference in New Issue
Block a user