vectorvein 0.2.61__py3-none-any.whl → 0.2.63__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 +10 -6
- vectorvein/workflow/utils/json_to_code.py +11 -9
- {vectorvein-0.2.61.dist-info → vectorvein-0.2.63.dist-info}/METADATA +1 -1
- {vectorvein-0.2.61.dist-info → vectorvein-0.2.63.dist-info}/RECORD +6 -6
- {vectorvein-0.2.61.dist-info → vectorvein-0.2.63.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.61.dist-info → vectorvein-0.2.63.dist-info}/entry_points.txt +0 -0
@@ -1,10 +1,14 @@
|
|
1
1
|
import uuid
|
2
|
-
from typing import Dict, Any, Optional, List, Union
|
2
|
+
from typing import Dict, Any, Optional, List, Union, TYPE_CHECKING
|
3
3
|
|
4
|
-
from .port import
|
4
|
+
from .port import InputPort, OutputPort
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
if TYPE_CHECKING:
|
8
|
+
from .port import PortType, Port
|
9
|
+
|
10
|
+
|
11
|
+
class PortsDict(Dict[str, "Port"]):
|
8
12
|
"""自定义字典类,用于管理节点的端口,并强制执行端口添加权限。"""
|
9
13
|
|
10
14
|
def __init__(self, owner_node: "Node", *args, **kwargs):
|
@@ -12,7 +16,7 @@ class PortsDict(Dict[str, Port]):
|
|
12
16
|
self._owner_node = owner_node
|
13
17
|
self._initializing = True
|
14
18
|
|
15
|
-
def __setitem__(self, key: str, value: Port) -> None:
|
19
|
+
def __setitem__(self, key: str, value: "Port") -> None:
|
16
20
|
if self._initializing or key in self:
|
17
21
|
super().__setitem__(key, value)
|
18
22
|
return
|
@@ -40,7 +44,7 @@ class Node:
|
|
40
44
|
category: str,
|
41
45
|
task_name: str,
|
42
46
|
description: str = "",
|
43
|
-
ports: Optional[Dict[str,
|
47
|
+
ports: Optional[Dict[str, "Port"]] = None,
|
44
48
|
node_id: Optional[str] = None,
|
45
49
|
position: Optional[Dict[str, float]] = None,
|
46
50
|
seleted_workflow_title: str = "",
|
@@ -74,7 +78,7 @@ class Node:
|
|
74
78
|
def add_port(
|
75
79
|
self,
|
76
80
|
name: str,
|
77
|
-
port_type: Union[PortType, str],
|
81
|
+
port_type: Union["PortType", str],
|
78
82
|
show: bool = False,
|
79
83
|
value: Any = None,
|
80
84
|
options: Optional[List[Any]] = None,
|
@@ -142,8 +142,8 @@ def generate_python_code(
|
|
142
142
|
code.append("")
|
143
143
|
|
144
144
|
# 生成节点实例化代码
|
145
|
-
for
|
146
|
-
code.append(f"{
|
145
|
+
for node_info in node_instances.values():
|
146
|
+
code.append(f"{node_info['var_name']} = {node_info['type']}()")
|
147
147
|
|
148
148
|
code.append("")
|
149
149
|
code.append("workflow = Workflow()")
|
@@ -153,8 +153,8 @@ def generate_python_code(
|
|
153
153
|
code.append(f"workflow.add_nodes([\n{'\n'.join(node_list)}\n])")
|
154
154
|
|
155
155
|
code.append("")
|
156
|
-
for
|
157
|
-
for port in
|
156
|
+
for node_info in node_instances.values():
|
157
|
+
for port in node_info["add_ports"]:
|
158
158
|
params = [
|
159
159
|
f"name={to_python_str(port['name'])}",
|
160
160
|
f"port_type={to_python_str(port['field_type'])}",
|
@@ -166,13 +166,15 @@ def generate_python_code(
|
|
166
166
|
params.append(f"options={port['options']}")
|
167
167
|
if port.get("is_output"):
|
168
168
|
params.append(f"is_output={bool(port['is_output'])}")
|
169
|
-
|
169
|
+
if node_info["type"] == "ProgrammingFunction":
|
170
|
+
params.append(f'field_type="{port["type"]}"')
|
171
|
+
code.append(f"{node_info['var_name']}.add_port({', '.join(params)})")
|
170
172
|
|
171
|
-
for port_name in
|
172
|
-
code.append(f"{
|
173
|
+
for port_name in node_info["show_ports"]:
|
174
|
+
code.append(f"{node_info['var_name']}.ports['{port_name}'].show = True")
|
173
175
|
|
174
|
-
for port in
|
175
|
-
code.append(f"{
|
176
|
+
for port in node_info["values"]:
|
177
|
+
code.append(f"{node_info['var_name']}.ports['{port['name']}'].value = {to_python_str(port['value'])}")
|
176
178
|
|
177
179
|
code.append("")
|
178
180
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.63.dist-info/METADATA,sha256=bp_MfR1VH9x50C2uHRYOeHF77enWRykynnuWFX8eJe4,4570
|
2
|
+
vectorvein-0.2.63.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.63.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,7 +42,7 @@ 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=WtO4MkeMQr59zNl9N2ZoYiCZcVKxebSp1rKMPONmfqk,5628
|
46
46
|
vectorvein/workflow/graph/port.py,sha256=HcinzQqNP7ysTvBmi3c4iaWne8nV6m-BpFFX0jTrMIE,7122
|
47
47
|
vectorvein/workflow/graph/workflow.py,sha256=f5KAQUXTKii7UFYmSZeZZQ7JCKKPmJlUg0iFAfBEJQE,6366
|
48
48
|
vectorvein/workflow/nodes/__init__.py,sha256=dWrWtL3q0Vsn-MLgJ7gNgLCrwZ5BrqjrN2QFPNeBMuc,3240
|
@@ -62,6 +62,6 @@ 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/check.py,sha256=Oj_S5WQf4_Fr_ro3ipjZt9unKFSFcuwZrrSmrS9kVLE,10193
|
65
|
-
vectorvein/workflow/utils/json_to_code.py,sha256
|
65
|
+
vectorvein/workflow/utils/json_to_code.py,sha256=U9EF62D270Ff1D8JKH3Am_jwsiDkSLeC41MZz7rZ8hg,6257
|
66
66
|
vectorvein/workflow/utils/layout.py,sha256=j0bRD3uaXu40xCS6U6BGahBI8FrHa5MiF55GbTrZ1LM,4565
|
67
|
-
vectorvein-0.2.
|
67
|
+
vectorvein-0.2.63.dist-info/RECORD,,
|
File without changes
|
File without changes
|