mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-14 20:42:31 +08:00
fix: remove whitespace and deprecation cruft
Amp-Thread-ID: https://ampcode.com/threads/T-019c2be8-0b34-747e-b1f7-20a1a1e6c9df
This commit is contained in:
parent
3f18652588
commit
8db3d29298
@ -8,13 +8,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class NodeReplaceManager:
|
class NodeReplaceManager:
|
||||||
"""
|
"""Manages node replacement registrations."""
|
||||||
Manages node replacement registrations.
|
|
||||||
|
|
||||||
Stores replacements as instance state (not module-level globals) to support
|
|
||||||
process isolation via pyisolate, where extensions run in separate processes
|
|
||||||
and communicate via RPC.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._replacements: dict[str, list[NodeReplace]] = {}
|
self._replacements: dict[str, list[NodeReplace]] = {}
|
||||||
|
|||||||
@ -24,16 +24,7 @@ class ComfyAPI_latest(ComfyAPIBase):
|
|||||||
|
|
||||||
class NodeReplacement(ProxiedSingleton):
|
class NodeReplacement(ProxiedSingleton):
|
||||||
async def register(self, node_replace: 'node_replace.NodeReplace') -> None:
|
async def register(self, node_replace: 'node_replace.NodeReplace') -> None:
|
||||||
"""
|
"""Register a node replacement mapping."""
|
||||||
Register a node replacement mapping.
|
|
||||||
|
|
||||||
This async method supports process isolation via pyisolate, where
|
|
||||||
extensions run in separate processes. The call is RPC'd to the host
|
|
||||||
process where PromptServer and NodeReplaceManager live.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
node_replace: A NodeReplace object defining the old->new mapping
|
|
||||||
"""
|
|
||||||
from server import PromptServer
|
from server import PromptServer
|
||||||
PromptServer.instance.node_replace_manager.register(node_replace)
|
PromptServer.instance.node_replace_manager.register(node_replace)
|
||||||
|
|
||||||
|
|||||||
@ -1,27 +1,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import warnings
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def register_node_replacement(node_replace: NodeReplace):
|
|
||||||
"""
|
|
||||||
Register node replacement.
|
|
||||||
|
|
||||||
.. deprecated::
|
|
||||||
Use ``ComfyAPI.node_replacement.register()`` instead.
|
|
||||||
This synchronous function does not work with process isolation (pyisolate).
|
|
||||||
"""
|
|
||||||
warnings.warn(
|
|
||||||
"register_node_replacement() is deprecated. "
|
|
||||||
"Use 'await ComfyAPI.node_replacement.register()' instead for pyisolate compatibility.",
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=2
|
|
||||||
)
|
|
||||||
from server import PromptServer
|
|
||||||
PromptServer.instance.node_replace_manager.register(node_replace)
|
|
||||||
|
|
||||||
|
|
||||||
class NodeReplace:
|
class NodeReplace:
|
||||||
"""
|
"""
|
||||||
Defines a possible node replacement, mapping inputs and outputs of the old node to the new node.
|
Defines a possible node replacement, mapping inputs and outputs of the old node to the new node.
|
||||||
@ -42,9 +23,7 @@ class NodeReplace:
|
|||||||
self.output_mapping = output_mapping
|
self.output_mapping = output_mapping
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
"""
|
"""Create serializable representation of the node replacement."""
|
||||||
Create serializable representation of the node replacement.
|
|
||||||
"""
|
|
||||||
return {
|
return {
|
||||||
"new_node_id": self.new_node_id,
|
"new_node_id": self.new_node_id,
|
||||||
"old_node_id": self.old_node_id,
|
"old_node_id": self.old_node_id,
|
||||||
@ -70,9 +49,7 @@ class InputMap:
|
|||||||
}
|
}
|
||||||
|
|
||||||
class OldId(_Assign):
|
class OldId(_Assign):
|
||||||
"""
|
"""Connect the input of the old node with given id to new node when replacing."""
|
||||||
Connect the input of the old node with given id to new node when replacing.
|
|
||||||
"""
|
|
||||||
def __init__(self, old_id: str):
|
def __init__(self, old_id: str):
|
||||||
super().__init__("old_id")
|
super().__init__("old_id")
|
||||||
self.old_id = old_id
|
self.old_id = old_id
|
||||||
@ -83,9 +60,7 @@ class InputMap:
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SetValue(_Assign):
|
class SetValue(_Assign):
|
||||||
"""
|
"""Use the given value for the input of the new node when replacing; assumes input is a widget."""
|
||||||
Use the given value for the input of the new node when replacing; assumes input is a widget.
|
|
||||||
"""
|
|
||||||
def __init__(self, value: Any):
|
def __init__(self, value: Any):
|
||||||
super().__init__("set_value")
|
super().__init__("set_value")
|
||||||
self.value = value
|
self.value = value
|
||||||
@ -107,9 +82,7 @@ class InputMap:
|
|||||||
|
|
||||||
|
|
||||||
class OutputMap:
|
class OutputMap:
|
||||||
"""
|
"""Map outputs of node replacement via indexes, as that's how outputs are stored."""
|
||||||
Map outputs of node replacement via indexes, as that's how outputs are stored.
|
|
||||||
"""
|
|
||||||
def __init__(self, new_idx: int, old_idx: int):
|
def __init__(self, new_idx: int, old_idx: int):
|
||||||
self.new_idx = new_idx
|
self.new_idx = new_idx
|
||||||
self.old_idx = old_idx
|
self.old_idx = old_idx
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user