vectorvein 0.2.72__py3-none-any.whl → 0.2.74__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vectorvein/workflow/graph/node.py +6 -0
- vectorvein/workflow/graph/workflow.py +29 -2
- vectorvein/workflow/utils/check.py +28 -0
- {vectorvein-0.2.72.dist-info → vectorvein-0.2.74.dist-info}/METADATA +1 -1
- {vectorvein-0.2.72.dist-info → vectorvein-0.2.74.dist-info}/RECORD +7 -7
- {vectorvein-0.2.72.dist-info → vectorvein-0.2.74.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.72.dist-info → vectorvein-0.2.74.dist-info}/entry_points.txt +0 -0
@@ -88,12 +88,18 @@ class Node:
|
|
88
88
|
if is_output:
|
89
89
|
if not self.can_add_output_ports:
|
90
90
|
raise ValueError(f"Node<{self.id}> '{self.type}' does not allow adding output ports")
|
91
|
+
|
92
|
+
if self.has_port(name):
|
93
|
+
raise ValueError(f"Node<{self.id}> '{self.type}' already has a port named '{name}'")
|
91
94
|
self.ports[name] = OutputPort(
|
92
95
|
name=name, port_type=port_type, show=show, value=value, options=options, **kwargs
|
93
96
|
)
|
94
97
|
else:
|
95
98
|
if not self.can_add_input_ports:
|
96
99
|
raise ValueError(f"Node<{self.id}> '{self.type}' does not allow adding input ports")
|
100
|
+
|
101
|
+
if self.has_port(name):
|
102
|
+
raise ValueError(f"Node<{self.id}> '{self.type}' already has a port named '{name}'")
|
97
103
|
self.ports[name] = InputPort(
|
98
104
|
name=name, port_type=port_type, show=show, value=value, options=options, **kwargs
|
99
105
|
)
|
@@ -12,6 +12,7 @@ from ..utils.check import (
|
|
12
12
|
check_useless_nodes,
|
13
13
|
check_required_ports,
|
14
14
|
check_override_ports,
|
15
|
+
check_output_nodes_with_no_inputs,
|
15
16
|
)
|
16
17
|
|
17
18
|
|
@@ -68,6 +69,13 @@ class Workflow:
|
|
68
69
|
if not target_node_obj.has_input_port(target_port):
|
69
70
|
raise ValueError(f"Target node {target_node_id} has no input port: {target_port}")
|
70
71
|
|
72
|
+
# 确保目标端口是InputPort而不是OutputPort
|
73
|
+
target_port_obj = target_node_obj.ports[target_port]
|
74
|
+
if isinstance(target_port_obj, OutputPort):
|
75
|
+
raise ValueError(
|
76
|
+
f"The target port {target_port} of node {target_node_id} is an output port. OutputPort cannot be a connection target."
|
77
|
+
)
|
78
|
+
|
71
79
|
# 检查目标端口是否已有被连接的线
|
72
80
|
for edge in self.edges:
|
73
81
|
if edge.target == target_node_id and edge.target_handle == target_port:
|
@@ -138,6 +146,7 @@ class Workflow:
|
|
138
146
|
useless_nodes = check_useless_nodes(self)
|
139
147
|
required_ports = check_required_ports(self)
|
140
148
|
override_ports = check_override_ports(self)
|
149
|
+
output_nodes_with_no_inputs = check_output_nodes_with_no_inputs(self)
|
141
150
|
|
142
151
|
# 合并结果
|
143
152
|
result: WorkflowCheckResult = {
|
@@ -147,6 +156,7 @@ class Workflow:
|
|
147
156
|
"useless_nodes": useless_nodes,
|
148
157
|
"required_ports": required_ports,
|
149
158
|
"override_ports": override_ports,
|
159
|
+
"output_nodes_with_no_inputs": output_nodes_with_no_inputs,
|
150
160
|
}
|
151
161
|
|
152
162
|
return result
|
@@ -325,12 +335,29 @@ class Workflow:
|
|
325
335
|
|
326
336
|
# 创建边
|
327
337
|
for edge_data in data.get("edges", []):
|
338
|
+
# 获取目标节点和端口
|
339
|
+
target_node_id = edge_data["target"]
|
340
|
+
target_port_name = edge_data["targetHandle"]
|
341
|
+
|
342
|
+
# 查找目标节点
|
343
|
+
target_node = next((node for node in workflow.nodes if node.id == target_node_id), None)
|
344
|
+
if target_node is None:
|
345
|
+
raise ValueError(f"Target node not found: {target_node_id}")
|
346
|
+
|
347
|
+
# 检查目标端口是否是OutputPort
|
348
|
+
if target_node.has_port(target_port_name):
|
349
|
+
target_port = target_node.ports[target_port_name]
|
350
|
+
if isinstance(target_port, OutputPort):
|
351
|
+
raise ValueError(
|
352
|
+
f"The target port {target_port_name} of node {target_node_id} is an output port. OutputPort cannot be a connection target."
|
353
|
+
)
|
354
|
+
|
328
355
|
edge = Edge(
|
329
356
|
id=edge_data["id"],
|
330
357
|
source=edge_data["source"],
|
331
358
|
source_handle=edge_data["sourceHandle"],
|
332
|
-
target=
|
333
|
-
target_handle=
|
359
|
+
target=target_node_id,
|
360
|
+
target_handle=target_port_name,
|
334
361
|
animated=edge_data.get("animated", True),
|
335
362
|
type=edge_data.get("type", "default"),
|
336
363
|
)
|
@@ -25,6 +25,7 @@ class WorkflowCheckResult(TypedDict):
|
|
25
25
|
ui_warnings: UIWarning # UI相关警告
|
26
26
|
required_ports: list[tuple["Node", "Port"]] # 未连接的必填端口
|
27
27
|
override_ports: list[tuple["Node", "Port"]] # 被覆盖的端口
|
28
|
+
output_nodes_with_no_inputs: list["Node"] # 输出端口没有输入端口连接的节点
|
28
29
|
|
29
30
|
|
30
31
|
def check_dag(workflow: "Workflow"):
|
@@ -259,3 +260,30 @@ def check_override_ports(workflow: "Workflow") -> list[tuple["Node", "Port"]]:
|
|
259
260
|
override_ports.append((node, port))
|
260
261
|
|
261
262
|
return override_ports
|
263
|
+
|
264
|
+
|
265
|
+
def check_output_nodes_with_no_inputs(workflow: "Workflow") -> list["Node"]:
|
266
|
+
"""检查工作流中是否存在输出端口没有输入端口连接的节点。"""
|
267
|
+
output_nodes_with_no_inputs = []
|
268
|
+
|
269
|
+
# 找出所有连接的目标节点和端口
|
270
|
+
connected_targets = {(edge.target, edge.target_handle) for edge in workflow.edges}
|
271
|
+
|
272
|
+
# 遍历所有节点
|
273
|
+
for node in workflow.nodes:
|
274
|
+
# 只检查输出类节点
|
275
|
+
if hasattr(node, "category") and node.category == "outputs":
|
276
|
+
# 检查该节点是否有任何连接到其输入端口的边
|
277
|
+
has_input_connection = False
|
278
|
+
|
279
|
+
for port_name, port in node.ports.items():
|
280
|
+
if isinstance(port, InputPort):
|
281
|
+
if (node.id, port_name) in connected_targets:
|
282
|
+
has_input_connection = True
|
283
|
+
break
|
284
|
+
|
285
|
+
# 如果该输出节点没有任何输入连接,则添加到结果列表
|
286
|
+
if not has_input_connection:
|
287
|
+
output_nodes_with_no_inputs.append(node)
|
288
|
+
|
289
|
+
return output_nodes_with_no_inputs
|
@@ -1,6 +1,6 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.74.dist-info/METADATA,sha256=yfe3P46Pnisf2CF6ZEhzUzbNfLLUJLcncCzSgtb436U,4567
|
2
|
+
vectorvein-0.2.74.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.74.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
|
4
4
|
vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
vectorvein/api/__init__.py,sha256=lfY-XA46fgD2iIZTU0VYP8i07AwA03Egj4Qua0vUKrQ,738
|
6
6
|
vectorvein/api/client.py,sha256=xF-leKDQzVyyy9FnIRaz0k4eElYW1XbbzeRLcpnyk90,33047
|
@@ -42,9 +42,9 @@ vectorvein/utilities/media_processing.py,sha256=7KtbLFzOYIn1e9QTN9G6C76NH8CBlV9k
|
|
42
42
|
vectorvein/utilities/rate_limiter.py,sha256=dwolIUVw2wP83Odqpx0AAaE77de1GzxkYDGH4tM_u_4,10300
|
43
43
|
vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
|
44
44
|
vectorvein/workflow/graph/edge.py,sha256=1ckyyjCue_PLm7P1ItUfKOy6AKkemOpZ9m1WJ8UXIHQ,1072
|
45
|
-
vectorvein/workflow/graph/node.py,sha256=
|
45
|
+
vectorvein/workflow/graph/node.py,sha256=YdUL69ZIThqtELxnNdDTCiaONVPp5ZR76391Impy8SA,5910
|
46
46
|
vectorvein/workflow/graph/port.py,sha256=HcinzQqNP7ysTvBmi3c4iaWne8nV6m-BpFFX0jTrMIE,7122
|
47
|
-
vectorvein/workflow/graph/workflow.py,sha256=
|
47
|
+
vectorvein/workflow/graph/workflow.py,sha256=wK_A8YNjqaOu63xhHtnATBGnLzJim9MGlkjc1wgMpx4,15990
|
48
48
|
vectorvein/workflow/nodes/__init__.py,sha256=dWrWtL3q0Vsn-MLgJ7gNgLCrwZ5BrqjrN2QFPNeBMuc,3240
|
49
49
|
vectorvein/workflow/nodes/audio_generation.py,sha256=ZRFZ_ycMTSJ2LKmekctagQdJYTl-3q4TNOIKETpS9AM,5870
|
50
50
|
vectorvein/workflow/nodes/control_flows.py,sha256=fDySWek8Isbfznwn0thmbTwTP4c99w68Up9dlASAtIo,6805
|
@@ -62,7 +62,7 @@ vectorvein/workflow/nodes/vector_db.py,sha256=p9AT_E8ASbcYHZqHYTCIGvqkIqzxaFM4Ux
|
|
62
62
|
vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
|
63
63
|
vectorvein/workflow/nodes/web_crawlers.py,sha256=FB0bTimkk___p3Z5UwQx2YarJyQCc45jjnbXbgGA_qw,5640
|
64
64
|
vectorvein/workflow/utils/analyse.py,sha256=msmvyz35UTYTwqQR5sg9H0sm1vxmGDSmep9XxUrHvE0,14837
|
65
|
-
vectorvein/workflow/utils/check.py,sha256=
|
65
|
+
vectorvein/workflow/utils/check.py,sha256=B_NdwqIqnc7Ko2HHqFpfOmWVaAu21tPITe0szKfiZKc,11414
|
66
66
|
vectorvein/workflow/utils/json_to_code.py,sha256=P8dhhSNgKhTnW17qXNjLO2aLdb0rA8qMAWxhObol2TU,7295
|
67
67
|
vectorvein/workflow/utils/layout.py,sha256=j0bRD3uaXu40xCS6U6BGahBI8FrHa5MiF55GbTrZ1LM,4565
|
68
|
-
vectorvein-0.2.
|
68
|
+
vectorvein-0.2.74.dist-info/RECORD,,
|
File without changes
|
File without changes
|