@@ -21,33 +21,66 @@ def process(self):
21
21
22
22
CURRENT_START_EXECUTION_DATA = None
23
23
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
-
49
24
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
51
84
52
85
origin_func = server .PromptServer .send_sync
53
86
0 commit comments