Skip to content

Commit 8db3d29

Browse files
fix: remove whitespace and deprecation cruft
Amp-Thread-ID: https://ampcode.com/threads/T-019c2be8-0b34-747e-b1f7-20a1a1e6c9df
1 parent 3f18652 commit 8db3d29

File tree

3 files changed

+13
-55
lines changed

3 files changed

+13
-55
lines changed

app/node_replace_manager.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,30 @@
88

99

1010
class NodeReplaceManager:
11-
"""
12-
Manages node replacement registrations.
13-
14-
Stores replacements as instance state (not module-level globals) to support
15-
process isolation via pyisolate, where extensions run in separate processes
16-
and communicate via RPC.
17-
"""
18-
11+
"""Manages node replacement registrations."""
12+
1913
def __init__(self):
2014
self._replacements: dict[str, list[NodeReplace]] = {}
21-
15+
2216
def register(self, node_replace: NodeReplace):
2317
"""Register a node replacement mapping."""
2418
self._replacements.setdefault(node_replace.old_node_id, []).append(node_replace)
25-
19+
2620
def get_replacement(self, old_node_id: str) -> list[NodeReplace] | None:
2721
"""Get replacements for an old node ID."""
2822
return self._replacements.get(old_node_id)
29-
23+
3024
def has_replacement(self, old_node_id: str) -> bool:
3125
"""Check if a replacement exists for an old node ID."""
3226
return old_node_id in self._replacements
33-
27+
3428
def as_dict(self):
3529
"""Serialize all replacements to dict."""
3630
return {
37-
k: [v.as_dict() for v in v_list]
31+
k: [v.as_dict() for v in v_list]
3832
for k, v_list in self._replacements.items()
3933
}
40-
34+
4135
def add_routes(self, routes):
4236
@routes.get("/node_replacements")
4337
async def get_node_replacements(request):

comfy_api/latest/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@ class ComfyAPI_latest(ComfyAPIBase):
2424

2525
class NodeReplacement(ProxiedSingleton):
2626
async def register(self, node_replace: 'node_replace.NodeReplace') -> None:
27-
"""
28-
Register a node replacement mapping.
29-
30-
This async method supports process isolation via pyisolate, where
31-
extensions run in separate processes. The call is RPC'd to the host
32-
process where PromptServer and NodeReplaceManager live.
33-
34-
Args:
35-
node_replace: A NodeReplace object defining the old->new mapping
36-
"""
27+
"""Register a node replacement mapping."""
3728
from server import PromptServer
3829
PromptServer.instance.node_replace_manager.register(node_replace)
3930

comfy_api/latest/_node_replace.py

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
from __future__ import annotations
22

3-
import warnings
43
from typing import Any
54

65

7-
def register_node_replacement(node_replace: NodeReplace):
8-
"""
9-
Register node replacement.
10-
11-
.. deprecated::
12-
Use ``ComfyAPI.node_replacement.register()`` instead.
13-
This synchronous function does not work with process isolation (pyisolate).
14-
"""
15-
warnings.warn(
16-
"register_node_replacement() is deprecated. "
17-
"Use 'await ComfyAPI.node_replacement.register()' instead for pyisolate compatibility.",
18-
DeprecationWarning,
19-
stacklevel=2
20-
)
21-
from server import PromptServer
22-
PromptServer.instance.node_replace_manager.register(node_replace)
23-
24-
256
class NodeReplace:
267
"""
278
Defines a possible node replacement, mapping inputs and outputs of the old node to the new node.
@@ -42,9 +23,7 @@ def __init__(self,
4223
self.output_mapping = output_mapping
4324

4425
def as_dict(self):
45-
"""
46-
Create serializable representation of the node replacement.
47-
"""
26+
"""Create serializable representation of the node replacement."""
4827
return {
4928
"new_node_id": self.new_node_id,
5029
"old_node_id": self.old_node_id,
@@ -70,9 +49,7 @@ def as_dict(self):
7049
}
7150

7251
class OldId(_Assign):
73-
"""
74-
Connect the input of the old node with given id to new node when replacing.
75-
"""
52+
"""Connect the input of the old node with given id to new node when replacing."""
7653
def __init__(self, old_id: str):
7754
super().__init__("old_id")
7855
self.old_id = old_id
@@ -83,9 +60,7 @@ def as_dict(self):
8360
}
8461

8562
class SetValue(_Assign):
86-
"""
87-
Use the given value for the input of the new node when replacing; assumes input is a widget.
88-
"""
63+
"""Use the given value for the input of the new node when replacing; assumes input is a widget."""
8964
def __init__(self, value: Any):
9065
super().__init__("set_value")
9166
self.value = value
@@ -107,9 +82,7 @@ def as_dict(self):
10782

10883

10984
class OutputMap:
110-
"""
111-
Map outputs of node replacement via indexes, as that's how outputs are stored.
112-
"""
85+
"""Map outputs of node replacement via indexes, as that's how outputs are stored."""
11386
def __init__(self, new_idx: int, old_idx: int):
11487
self.new_idx = new_idx
11588
self.old_idx = old_idx

0 commit comments

Comments
 (0)