Skip to content

Commit

Permalink
refactor: ImpactControlBridge
Browse files Browse the repository at this point in the history
use interrupt_processing instead of raise exception.
  • Loading branch information
ltdrdata committed May 16, 2024
1 parent ecab0d5 commit fe662ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/impact/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os


version_code = [5, 5, 8]
version_code = [5, 5, 9]
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')

dependency_version = 20
Expand Down
21 changes: 8 additions & 13 deletions modules/impact/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import time

import execution
import folder_paths
import impact.impact_server
from server import PromptServer
from impact.utils import any_typ
import impact.core as core
import re

import nodes

class ImpactCompare:
@classmethod
Expand Down Expand Up @@ -646,20 +645,20 @@ def IS_CHANGED(self, value, mode, behavior=True, unique_id=None, prompt=None, ex
def doit(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pnginfo=None):
global error_skip_flag

nodes, links = workflow_to_map(extra_pnginfo['workflow'])
workflow_nodes, links = workflow_to_map(extra_pnginfo['workflow'])

active_nodes = []
mute_nodes = []
bypass_nodes = []

for link in nodes[unique_id]['outputs'][0]['links']:
for link in workflow_nodes[unique_id]['outputs'][0]['links']:
node_id = str(links[link][2])

next_nodes = []
impact.utils.collect_non_reroute_nodes(nodes, links, next_nodes, node_id)
impact.utils.collect_non_reroute_nodes(workflow_nodes, links, next_nodes, node_id)

for next_node_id in next_nodes:
node_mode = nodes[next_node_id]['mode']
node_mode = workflow_nodes[next_node_id]['mode']

if node_mode == 0:
active_nodes.append(next_node_id)
Expand All @@ -673,24 +672,21 @@ def doit(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pn
should_be_active_nodes = mute_nodes + bypass_nodes
if len(should_be_active_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_be_active_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")
nodes.interrupt_processing()

elif behavior:
# mute
should_be_mute_nodes = active_nodes + bypass_nodes
if len(should_be_mute_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'mutes': list(should_be_mute_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")
nodes.interrupt_processing()

else:
# bypass
should_be_bypass_nodes = active_nodes + mute_nodes
if len(should_be_bypass_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'bypasses': list(should_be_bypass_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")
nodes.interrupt_processing()

return (value, )

Expand All @@ -699,6 +695,5 @@ def doit(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pn


def handle_execution_error(**kwargs):
print(f" handled")
execution.PromptExecutor.handle_execution_error(**kwargs)

0 comments on commit fe662ed

Please sign in to comment.