Skip to content

Commit 22d68d3

Browse files
committed
Merge branch 'release/0.4.3'
2 parents 83be13f + 83d3c64 commit 22d68d3

File tree

3 files changed

+73
-28
lines changed

3 files changed

+73
-28
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
0.4.3
2+
---
3+
4+
### BUG Fix
5+
6+
1. Fix BUG: The ExecutionTime Node is not working with the latest version of ComfyUI.
7+
PR: https://github.com/ty0x2333/ComfyUI-Dev-Utils/pull/16
8+
9+
Thanks [hugovntr](https://github.com/hugovntr) .
10+
11+
ComfyUI commit: https://github.com/comfyanonymous/ComfyUI/tree/5cfe38f41c7091b0fd954877d9d7427a8b438b1a
12+
113
0.4.2
214
---
315

nodes/execution_time.py

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,66 @@ def process(self):
2121

2222
CURRENT_START_EXECUTION_DATA = None
2323

24-
origin_recursive_execute = execution.recursive_execute
25-
26-
27-
def swizzle_origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id, outputs_ui,
28-
object_storage):
29-
unique_id = current_item
30-
class_type = prompt[unique_id]['class_type']
31-
last_node_id = server.last_node_id
32-
result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
33-
outputs_ui,
34-
object_storage)
35-
if CURRENT_START_EXECUTION_DATA:
36-
start_time = CURRENT_START_EXECUTION_DATA['nodes_start_perf_time'].get(unique_id)
37-
if start_time:
38-
end_time = time.perf_counter()
39-
execution_time = end_time - start_time
40-
if server.client_id is not None and last_node_id != server.last_node_id:
41-
server.send_sync(
42-
"TyDev-Utils.ExecutionTime.executed",
43-
{"node": unique_id, "prompt_id": prompt_id, "execution_time": int(execution_time * 1000)},
44-
server.client_id
45-
)
46-
print(f"#{unique_id} [{class_type}]: {execution_time:.2f}s")
47-
return result
48-
4924

50-
execution.recursive_execute = swizzle_origin_recursive_execute
25+
def handle_execute(class_type, last_node_id, prompt_id, server, unique_id):
26+
if not CURRENT_START_EXECUTION_DATA:
27+
return
28+
start_time = CURRENT_START_EXECUTION_DATA['nodes_start_perf_time'].get(unique_id)
29+
if start_time:
30+
end_time = time.perf_counter()
31+
execution_time = end_time - start_time
32+
if server.client_id is not None and last_node_id != server.last_node_id:
33+
server.send_sync(
34+
"TyDev-Utils.ExecutionTime.executed",
35+
{"node": unique_id, "prompt_id": prompt_id, "execution_time": int(execution_time * 1000)},
36+
server.client_id
37+
)
38+
print(f"#{unique_id} [{class_type}]: {execution_time:.2f}s")
39+
40+
41+
try:
42+
origin_execute = execution.execute
43+
44+
45+
def swizzle_execute(server, dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list,
46+
pending_subgraph_results):
47+
unique_id = current_item
48+
class_type = dynprompt.get_node(unique_id)['class_type']
49+
last_node_id = server.last_node_id
50+
result = origin_execute(server, dynprompt, caches, current_item, extra_data, executed, prompt_id,
51+
execution_list,
52+
pending_subgraph_results)
53+
handle_execute(class_type, last_node_id, prompt_id, server, unique_id)
54+
return result
55+
56+
57+
execution.execute = swizzle_execute
58+
except Exception as e:
59+
pass
60+
61+
# region: Deprecated
62+
try:
63+
# The execute method in the old version of ComfyUI is now deprecated.
64+
origin_recursive_execute = execution.recursive_execute
65+
66+
67+
def swizzle_origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
68+
outputs_ui,
69+
object_storage):
70+
unique_id = current_item
71+
class_type = prompt[unique_id]['class_type']
72+
last_node_id = server.last_node_id
73+
result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
74+
outputs_ui,
75+
object_storage)
76+
handle_execute(class_type, last_node_id, prompt_id, server, unique_id)
77+
return result
78+
79+
80+
execution.recursive_execute = swizzle_origin_recursive_execute
81+
except Exception as e:
82+
pass
83+
# endregion
5184

5285
origin_func = server.PromptServer.send_sync
5386

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[project]
22
name = "comfyui-dev-utils"
33
description = "Execution Time Analysis, Reroute Enhancement, Node collection for developers."
4-
dynamic = "0.4.2"
5-
license = { file = "LICENSE" }
4+
dynamic = "0.4.3"
5+
license = { text = "MIT License" }
66
dependencies = ["aiohttp-sse"]
77

88
[project.urls]

0 commit comments

Comments
 (0)