Spaces:
Running
Running
Update tests, width/height must be set now.
Browse files
lynxkite-app/tests/test_main.py
CHANGED
@@ -44,6 +44,8 @@ def test_save_and_load():
|
|
44 |
"params": {"param1": "value"},
|
45 |
},
|
46 |
"position": {"x": -493.5496596237119, "y": 20.90123252513356},
|
|
|
|
|
47 |
}
|
48 |
],
|
49 |
"edges": [],
|
|
|
44 |
"params": {"param1": "value"},
|
45 |
},
|
46 |
"position": {"x": -493.5496596237119, "y": 20.90123252513356},
|
47 |
+
"width": 100,
|
48 |
+
"height": 100,
|
49 |
}
|
50 |
],
|
51 |
"edges": [],
|
lynxkite-core/src/lynxkite/core/workspace.py
CHANGED
@@ -203,27 +203,27 @@ class Workspace(BaseConfig):
|
|
203 |
nc["data"] = pycrdt.Map()
|
204 |
np._crdt = nc
|
205 |
|
206 |
-
def add_node(self, func):
|
207 |
"""For convenience in e.g. tests."""
|
208 |
random_string = os.urandom(4).hex()
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
status=NodeStatus.planned,
|
219 |
-
),
|
220 |
-
position=Position(x=0, y=0),
|
221 |
-
)
|
222 |
self.nodes.append(node)
|
223 |
return node
|
224 |
|
225 |
def add_edge(
|
226 |
-
self,
|
|
|
|
|
|
|
|
|
227 |
):
|
228 |
"""For convenience in e.g. tests."""
|
229 |
edge = WorkspaceEdge(
|
|
|
203 |
nc["data"] = pycrdt.Map()
|
204 |
np._crdt = nc
|
205 |
|
206 |
+
def add_node(self, func=None, **kwargs):
|
207 |
"""For convenience in e.g. tests."""
|
208 |
random_string = os.urandom(4).hex()
|
209 |
+
if func:
|
210 |
+
kwargs["type"] = func.__op__.type
|
211 |
+
kwargs["data"] = WorkspaceNodeData(title=func.__op__.name, params={})
|
212 |
+
kwargs.setdefault("type", "basic")
|
213 |
+
kwargs.setdefault("id", f"{kwargs['data'].title} {random_string}")
|
214 |
+
kwargs.setdefault("position", Position(x=0, y=0))
|
215 |
+
kwargs.setdefault("width", 100)
|
216 |
+
kwargs.setdefault("height", 100)
|
217 |
+
node = WorkspaceNode(**kwargs)
|
|
|
|
|
|
|
|
|
218 |
self.nodes.append(node)
|
219 |
return node
|
220 |
|
221 |
def add_edge(
|
222 |
+
self,
|
223 |
+
source: WorkspaceNode,
|
224 |
+
sourceHandle: str,
|
225 |
+
target: WorkspaceNode,
|
226 |
+
targetHandle: str,
|
227 |
):
|
228 |
"""For convenience in e.g. tests."""
|
229 |
edge = WorkspaceEdge(
|
lynxkite-core/tests/test_workspace.py
CHANGED
@@ -6,21 +6,15 @@ from lynxkite.core import workspace
|
|
6 |
|
7 |
def test_save_load():
|
8 |
ws = workspace.Workspace(env="test")
|
9 |
-
ws.
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
data=workspace.WorkspaceNodeData(title="Node 1", params={}),
|
14 |
-
position=workspace.Position(x=0, y=0),
|
15 |
-
)
|
16 |
)
|
17 |
-
ws.
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
data=workspace.WorkspaceNodeData(title="Node 2", params={}),
|
22 |
-
position=workspace.Position(x=0, y=0),
|
23 |
-
)
|
24 |
)
|
25 |
ws.edges.append(
|
26 |
workspace.WorkspaceEdge(
|
@@ -72,21 +66,15 @@ def populate_ops_catalog():
|
|
72 |
|
73 |
def test_update_metadata():
|
74 |
ws = workspace.Workspace(env="test")
|
75 |
-
ws.
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
data=workspace.WorkspaceNodeData(title="Test Operation", params={}),
|
80 |
-
position=workspace.Position(x=0, y=0),
|
81 |
-
)
|
82 |
)
|
83 |
-
ws.
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
data=workspace.WorkspaceNodeData(title="Unknown Operation", params={}),
|
88 |
-
position=workspace.Position(x=0, y=0),
|
89 |
-
)
|
90 |
)
|
91 |
ws.update_metadata()
|
92 |
assert ws.nodes[0].data.meta.name == "Test Operation"
|
|
|
6 |
|
7 |
def test_save_load():
|
8 |
ws = workspace.Workspace(env="test")
|
9 |
+
ws.add_node(
|
10 |
+
id="1",
|
11 |
+
type="node_type",
|
12 |
+
data=workspace.WorkspaceNodeData(title="Node 1", params={}),
|
|
|
|
|
|
|
13 |
)
|
14 |
+
ws.add_node(
|
15 |
+
id="2",
|
16 |
+
type="node_type",
|
17 |
+
data=workspace.WorkspaceNodeData(title="Node 2", params={}),
|
|
|
|
|
|
|
18 |
)
|
19 |
ws.edges.append(
|
20 |
workspace.WorkspaceEdge(
|
|
|
66 |
|
67 |
def test_update_metadata():
|
68 |
ws = workspace.Workspace(env="test")
|
69 |
+
ws.add_node(
|
70 |
+
id="1",
|
71 |
+
type="basic",
|
72 |
+
data=workspace.WorkspaceNodeData(title="Test Operation", params={}),
|
|
|
|
|
|
|
73 |
)
|
74 |
+
ws.add_node(
|
75 |
+
id="2",
|
76 |
+
type="basic",
|
77 |
+
data=workspace.WorkspaceNodeData(title="Unknown Operation", params={}),
|
|
|
|
|
|
|
78 |
)
|
79 |
ws.update_metadata()
|
80 |
assert ws.nodes[0].data.meta.name == "Test Operation"
|
lynxkite-graph-analytics/tests/test_lynxkite_ops.py
CHANGED
@@ -8,13 +8,11 @@ from lynxkite_graph_analytics.core import Bundle, execute, ENV
|
|
8 |
|
9 |
async def test_execute_operation_not_in_catalog():
|
10 |
ws = workspace.Workspace(env=ENV)
|
11 |
-
ws.
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
position=workspace.Position(x=0, y=0),
|
17 |
-
)
|
18 |
)
|
19 |
await execute(ws)
|
20 |
assert ws.nodes[0].data.error == "Operation not found in catalog"
|
@@ -43,37 +41,29 @@ async def test_execute_operation_inputs_correct_cast():
|
|
43 |
return bundle
|
44 |
|
45 |
ws = workspace.Workspace(env="test")
|
46 |
-
ws.
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
position=workspace.Position(x=0, y=0),
|
52 |
-
)
|
53 |
)
|
54 |
-
ws.
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
position=workspace.Position(x=100, y=0),
|
60 |
-
)
|
61 |
)
|
62 |
-
ws.
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
position=workspace.Position(x=200, y=0),
|
68 |
-
)
|
69 |
)
|
70 |
-
ws.
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
position=workspace.Position(x=300, y=0),
|
76 |
-
)
|
77 |
)
|
78 |
ws.edges = [
|
79 |
workspace.WorkspaceEdge(
|
@@ -109,29 +99,23 @@ async def test_multiple_inputs():
|
|
109 |
return a < b
|
110 |
|
111 |
ws = workspace.Workspace(env="test")
|
112 |
-
ws.
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
position=workspace.Position(x=0, y=0),
|
118 |
-
)
|
119 |
)
|
120 |
-
ws.
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
position=workspace.Position(x=100, y=0),
|
126 |
-
)
|
127 |
)
|
128 |
-
ws.
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
position=workspace.Position(x=200, y=0),
|
134 |
-
)
|
135 |
)
|
136 |
ws.edges = [
|
137 |
workspace.WorkspaceEdge(
|
|
|
8 |
|
9 |
async def test_execute_operation_not_in_catalog():
|
10 |
ws = workspace.Workspace(env=ENV)
|
11 |
+
ws.add_node(
|
12 |
+
id="1",
|
13 |
+
type="node_type",
|
14 |
+
data=workspace.WorkspaceNodeData(title="Non existing op", params={}),
|
15 |
+
position=workspace.Position(x=0, y=0),
|
|
|
|
|
16 |
)
|
17 |
await execute(ws)
|
18 |
assert ws.nodes[0].data.error == "Operation not found in catalog"
|
|
|
41 |
return bundle
|
42 |
|
43 |
ws = workspace.Workspace(env="test")
|
44 |
+
ws.add_node(
|
45 |
+
id="1",
|
46 |
+
type="node_type",
|
47 |
+
data=workspace.WorkspaceNodeData(title="Create Bundle", params={}),
|
48 |
+
position=workspace.Position(x=0, y=0),
|
|
|
|
|
49 |
)
|
50 |
+
ws.add_node(
|
51 |
+
id="2",
|
52 |
+
type="node_type",
|
53 |
+
data=workspace.WorkspaceNodeData(title="Bundle to Graph", params={}),
|
54 |
+
position=workspace.Position(x=100, y=0),
|
|
|
|
|
55 |
)
|
56 |
+
ws.add_node(
|
57 |
+
id="3",
|
58 |
+
type="node_type",
|
59 |
+
data=workspace.WorkspaceNodeData(title="Graph to Bundle", params={}),
|
60 |
+
position=workspace.Position(x=200, y=0),
|
|
|
|
|
61 |
)
|
62 |
+
ws.add_node(
|
63 |
+
id="4",
|
64 |
+
type="node_type",
|
65 |
+
data=workspace.WorkspaceNodeData(title="Dataframe to Bundle", params={}),
|
66 |
+
position=workspace.Position(x=300, y=0),
|
|
|
|
|
67 |
)
|
68 |
ws.edges = [
|
69 |
workspace.WorkspaceEdge(
|
|
|
99 |
return a < b
|
100 |
|
101 |
ws = workspace.Workspace(env="test")
|
102 |
+
ws.add_node(
|
103 |
+
id="one",
|
104 |
+
type="cool",
|
105 |
+
data=workspace.WorkspaceNodeData(title="One", params={}),
|
106 |
+
position=workspace.Position(x=0, y=0),
|
|
|
|
|
107 |
)
|
108 |
+
ws.add_node(
|
109 |
+
id="two",
|
110 |
+
type="cool",
|
111 |
+
data=workspace.WorkspaceNodeData(title="Two", params={}),
|
112 |
+
position=workspace.Position(x=100, y=0),
|
|
|
|
|
113 |
)
|
114 |
+
ws.add_node(
|
115 |
+
id="smaller",
|
116 |
+
type="cool",
|
117 |
+
data=workspace.WorkspaceNodeData(title="Smaller?", params={}),
|
118 |
+
position=workspace.Position(x=200, y=0),
|
|
|
|
|
119 |
)
|
120 |
ws.edges = [
|
121 |
workspace.WorkspaceEdge(
|
lynxkite-graph-analytics/tests/test_pytorch_model_ops.py
CHANGED
@@ -9,16 +9,9 @@ def make_ws(env, nodes: dict[str, dict], edges: list[tuple[str, str]]):
|
|
9 |
for id, data in nodes.items():
|
10 |
title = data["title"]
|
11 |
del data["title"]
|
12 |
-
ws.
|
13 |
-
|
14 |
-
|
15 |
-
type="basic",
|
16 |
-
data=workspace.WorkspaceNodeData(title=title, params=data),
|
17 |
-
position=workspace.Position(
|
18 |
-
x=data.get("x", 0),
|
19 |
-
y=data.get("y", 0),
|
20 |
-
),
|
21 |
-
)
|
22 |
)
|
23 |
ws.edges = [
|
24 |
workspace.WorkspaceEdge(
|
|
|
9 |
for id, data in nodes.items():
|
10 |
title = data["title"]
|
11 |
del data["title"]
|
12 |
+
ws.add_node(
|
13 |
+
id=id,
|
14 |
+
data=workspace.WorkspaceNodeData(title=title, params=data),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
)
|
16 |
ws.edges = [
|
17 |
workspace.WorkspaceEdge(
|