mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-08-02 11:16:36 +00:00
Moved ExecutionBlocker to graph_utils.py, maintained backwards compatibility
This commit is contained in:
parent
babd7bbf00
commit
ccfa2a80ff
@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
|||||||
from comfy_api.internal import (_ComfyNodeInternal, _NodeOutputInternal, classproperty, copy_class, first_real_override, is_class,
|
from comfy_api.internal import (_ComfyNodeInternal, _NodeOutputInternal, classproperty, copy_class, first_real_override, is_class,
|
||||||
prune_dict, shallow_clone_class)
|
prune_dict, shallow_clone_class)
|
||||||
from comfy_api.latest._resources import Resources, ResourcesLocal
|
from comfy_api.latest._resources import Resources, ResourcesLocal
|
||||||
from comfy_execution.graph import ExecutionBlocker
|
from comfy_execution.graph_utils import ExecutionBlocker
|
||||||
|
|
||||||
# from comfy_extras.nodes_images import SVG as SVG_ # NOTE: needs to be moved before can be imported due to circular reference
|
# from comfy_extras.nodes_images import SVG as SVG_ # NOTE: needs to be moved before can be imported due to circular reference
|
||||||
|
|
||||||
|
@ -4,9 +4,12 @@ from typing import Type, Literal
|
|||||||
import nodes
|
import nodes
|
||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
from comfy_execution.graph_utils import is_link
|
from comfy_execution.graph_utils import is_link, ExecutionBlocker
|
||||||
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, InputTypeOptions
|
from comfy.comfy_types.node_typing import ComfyNodeABC, InputTypeDict, InputTypeOptions
|
||||||
|
|
||||||
|
# NOTE: ExecutionBlocker code got moved to graph_utils.py to prevent torch being imported too soon during unit tests
|
||||||
|
ExecutionBlocker = ExecutionBlocker
|
||||||
|
|
||||||
class DependencyCycleError(Exception):
|
class DependencyCycleError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -294,21 +297,3 @@ class ExecutionList(TopologicalSort):
|
|||||||
del blocked_by[node_id]
|
del blocked_by[node_id]
|
||||||
to_remove = [node_id for node_id in blocked_by if len(blocked_by[node_id]) == 0]
|
to_remove = [node_id for node_id in blocked_by if len(blocked_by[node_id]) == 0]
|
||||||
return list(blocked_by.keys())
|
return list(blocked_by.keys())
|
||||||
|
|
||||||
class ExecutionBlocker:
|
|
||||||
"""
|
|
||||||
Return this from a node and any users will be blocked with the given error message.
|
|
||||||
If the message is None, execution will be blocked silently instead.
|
|
||||||
Generally, you should avoid using this functionality unless absolutely necessary. Whenever it's
|
|
||||||
possible, a lazy input will be more efficient and have a better user experience.
|
|
||||||
This functionality is useful in two cases:
|
|
||||||
1. You want to conditionally prevent an output node from executing. (Particularly a built-in node
|
|
||||||
like SaveImage. For your own output nodes, I would recommend just adding a BOOL input and using
|
|
||||||
lazy evaluation to let it conditionally disable itself.)
|
|
||||||
2. You have a node with multiple possible outputs, some of which are invalid and should not be used.
|
|
||||||
(I would recommend not making nodes like this in the future -- instead, make multiple nodes with
|
|
||||||
different outputs. Unfortunately, there are several popular existing nodes using this pattern.)
|
|
||||||
"""
|
|
||||||
def __init__(self, message):
|
|
||||||
self.message = message
|
|
||||||
|
|
||||||
|
@ -137,3 +137,19 @@ def add_graph_prefix(graph, outputs, prefix):
|
|||||||
|
|
||||||
return new_graph, tuple(new_outputs)
|
return new_graph, tuple(new_outputs)
|
||||||
|
|
||||||
|
class ExecutionBlocker:
|
||||||
|
"""
|
||||||
|
Return this from a node and any users will be blocked with the given error message.
|
||||||
|
If the message is None, execution will be blocked silently instead.
|
||||||
|
Generally, you should avoid using this functionality unless absolutely necessary. Whenever it's
|
||||||
|
possible, a lazy input will be more efficient and have a better user experience.
|
||||||
|
This functionality is useful in two cases:
|
||||||
|
1. You want to conditionally prevent an output node from executing. (Particularly a built-in node
|
||||||
|
like SaveImage. For your own output nodes, I would recommend just adding a BOOL input and using
|
||||||
|
lazy evaluation to let it conditionally disable itself.)
|
||||||
|
2. You have a node with multiple possible outputs, some of which are invalid and should not be used.
|
||||||
|
(I would recommend not making nodes like this in the future -- instead, make multiple nodes with
|
||||||
|
different outputs. Unfortunately, there are several popular existing nodes using this pattern.)
|
||||||
|
"""
|
||||||
|
def __init__(self, message):
|
||||||
|
self.message = message
|
||||||
|
Loading…
x
Reference in New Issue
Block a user