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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"edges": [
|
| 3 |
+
{
|
| 4 |
+
"id": "Multi-output example 1 one View tables 1 bundle",
|
| 5 |
+
"source": "Multi-output example 1",
|
| 6 |
+
"sourceHandle": "one",
|
| 7 |
+
"target": "View tables 1",
|
| 8 |
+
"targetHandle": "bundle"
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"id": "Multi-output example 1 two View tables 2 bundle",
|
| 12 |
+
"source": "Multi-output example 1",
|
| 13 |
+
"sourceHandle": "two",
|
| 14 |
+
"target": "View tables 2",
|
| 15 |
+
"targetHandle": "bundle"
|
| 16 |
+
}
|
| 17 |
+
],
|
| 18 |
+
"env": "LynxKite Graph Analytics",
|
| 19 |
+
"nodes": [
|
| 20 |
+
{
|
| 21 |
+
"data": {
|
| 22 |
+
"__execution_delay": 0.0,
|
| 23 |
+
"collapsed": false,
|
| 24 |
+
"display": null,
|
| 25 |
+
"error": null,
|
| 26 |
+
"input_metadata": [],
|
| 27 |
+
"meta": {
|
| 28 |
+
"color": "orange",
|
| 29 |
+
"doc": [
|
| 30 |
+
{
|
| 31 |
+
"kind": "text",
|
| 32 |
+
"value": "Returns two outputs. Also demonstrates Numpy-style docstrings."
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"kind": "parameters",
|
| 36 |
+
"value": [
|
| 37 |
+
{
|
| 38 |
+
"annotation": "int",
|
| 39 |
+
"description": "Number of elements in output \"one\".",
|
| 40 |
+
"name": "a_limit"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"annotation": "int",
|
| 44 |
+
"description": "Number of elements in output \"two\".",
|
| 45 |
+
"name": "b_limit"
|
| 46 |
+
}
|
| 47 |
+
]
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"kind": "returns",
|
| 51 |
+
"value": [
|
| 52 |
+
{
|
| 53 |
+
"annotation": "A dict with two DataFrames in it.",
|
| 54 |
+
"description": "",
|
| 55 |
+
"name": ""
|
| 56 |
+
}
|
| 57 |
+
]
|
| 58 |
+
}
|
| 59 |
+
],
|
| 60 |
+
"inputs": [],
|
| 61 |
+
"name": "Multi-output example",
|
| 62 |
+
"outputs": [
|
| 63 |
+
{
|
| 64 |
+
"name": "one",
|
| 65 |
+
"position": "right",
|
| 66 |
+
"type": {
|
| 67 |
+
"type": "None"
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"name": "two",
|
| 72 |
+
"position": "right",
|
| 73 |
+
"type": {
|
| 74 |
+
"type": "None"
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
],
|
| 78 |
+
"params": [
|
| 79 |
+
{
|
| 80 |
+
"default": 4,
|
| 81 |
+
"name": "a_limit",
|
| 82 |
+
"type": {
|
| 83 |
+
"type": "<class 'int'>"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"default": 10,
|
| 88 |
+
"name": "b_limit",
|
| 89 |
+
"type": {
|
| 90 |
+
"type": "<class 'int'>"
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
],
|
| 94 |
+
"type": "basic"
|
| 95 |
+
},
|
| 96 |
+
"params": {
|
| 97 |
+
"a_limit": "2",
|
| 98 |
+
"b_limit": "10"
|
| 99 |
+
},
|
| 100 |
+
"status": "done",
|
| 101 |
+
"title": "Multi-output example"
|
| 102 |
+
},
|
| 103 |
+
"dragHandle": ".bg-primary",
|
| 104 |
+
"height": 275.0,
|
| 105 |
+
"id": "Multi-output example 1",
|
| 106 |
+
"position": {
|
| 107 |
+
"x": 86.0,
|
| 108 |
+
"y": 33.0
|
| 109 |
+
},
|
| 110 |
+
"type": "basic",
|
| 111 |
+
"width": 200.0
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"data": {
|
| 115 |
+
"display": {
|
| 116 |
+
"dataframes": {
|
| 117 |
+
"df": {
|
| 118 |
+
"columns": [
|
| 119 |
+
"a"
|
| 120 |
+
],
|
| 121 |
+
"data": [
|
| 122 |
+
[
|
| 123 |
+
0
|
| 124 |
+
],
|
| 125 |
+
[
|
| 126 |
+
1
|
| 127 |
+
]
|
| 128 |
+
]
|
| 129 |
+
}
|
| 130 |
+
},
|
| 131 |
+
"other": {},
|
| 132 |
+
"relations": []
|
| 133 |
+
},
|
| 134 |
+
"error": null,
|
| 135 |
+
"input_metadata": [
|
| 136 |
+
{
|
| 137 |
+
"dataframes": {
|
| 138 |
+
"df": {
|
| 139 |
+
"columns": [
|
| 140 |
+
"a"
|
| 141 |
+
]
|
| 142 |
+
}
|
| 143 |
+
},
|
| 144 |
+
"other": {},
|
| 145 |
+
"relations": []
|
| 146 |
+
}
|
| 147 |
+
],
|
| 148 |
+
"meta": {
|
| 149 |
+
"color": "orange",
|
| 150 |
+
"doc": null,
|
| 151 |
+
"inputs": [
|
| 152 |
+
{
|
| 153 |
+
"name": "bundle",
|
| 154 |
+
"position": "left",
|
| 155 |
+
"type": {
|
| 156 |
+
"type": "<class 'lynxkite_graph_analytics.core.Bundle'>"
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
],
|
| 160 |
+
"name": "View tables",
|
| 161 |
+
"outputs": [],
|
| 162 |
+
"params": [
|
| 163 |
+
{
|
| 164 |
+
"default": 100,
|
| 165 |
+
"name": "limit",
|
| 166 |
+
"type": {
|
| 167 |
+
"type": "<class 'int'>"
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
],
|
| 171 |
+
"type": "table_view"
|
| 172 |
+
},
|
| 173 |
+
"params": {
|
| 174 |
+
"limit": 100.0
|
| 175 |
+
},
|
| 176 |
+
"status": "done",
|
| 177 |
+
"title": "View tables"
|
| 178 |
+
},
|
| 179 |
+
"dragHandle": ".bg-primary",
|
| 180 |
+
"height": 200.0,
|
| 181 |
+
"id": "View tables 1",
|
| 182 |
+
"position": {
|
| 183 |
+
"x": 485.0,
|
| 184 |
+
"y": -31.0
|
| 185 |
+
},
|
| 186 |
+
"type": "table_view",
|
| 187 |
+
"width": 200.0
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"data": {
|
| 191 |
+
"display": {
|
| 192 |
+
"dataframes": {
|
| 193 |
+
"df": {
|
| 194 |
+
"columns": [
|
| 195 |
+
"b"
|
| 196 |
+
],
|
| 197 |
+
"data": [
|
| 198 |
+
[
|
| 199 |
+
0
|
| 200 |
+
],
|
| 201 |
+
[
|
| 202 |
+
1
|
| 203 |
+
],
|
| 204 |
+
[
|
| 205 |
+
2
|
| 206 |
+
],
|
| 207 |
+
[
|
| 208 |
+
3
|
| 209 |
+
],
|
| 210 |
+
[
|
| 211 |
+
4
|
| 212 |
+
],
|
| 213 |
+
[
|
| 214 |
+
5
|
| 215 |
+
],
|
| 216 |
+
[
|
| 217 |
+
6
|
| 218 |
+
],
|
| 219 |
+
[
|
| 220 |
+
7
|
| 221 |
+
],
|
| 222 |
+
[
|
| 223 |
+
8
|
| 224 |
+
],
|
| 225 |
+
[
|
| 226 |
+
9
|
| 227 |
+
]
|
| 228 |
+
]
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
"other": {},
|
| 232 |
+
"relations": []
|
| 233 |
+
},
|
| 234 |
+
"error": null,
|
| 235 |
+
"input_metadata": [
|
| 236 |
+
{
|
| 237 |
+
"dataframes": {
|
| 238 |
+
"df": {
|
| 239 |
+
"columns": [
|
| 240 |
+
"b"
|
| 241 |
+
]
|
| 242 |
+
}
|
| 243 |
+
},
|
| 244 |
+
"other": {},
|
| 245 |
+
"relations": []
|
| 246 |
+
}
|
| 247 |
+
],
|
| 248 |
+
"meta": {
|
| 249 |
+
"color": "orange",
|
| 250 |
+
"doc": null,
|
| 251 |
+
"inputs": [
|
| 252 |
+
{
|
| 253 |
+
"name": "bundle",
|
| 254 |
+
"position": "left",
|
| 255 |
+
"type": {
|
| 256 |
+
"type": "<class 'lynxkite_graph_analytics.core.Bundle'>"
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
],
|
| 260 |
+
"name": "View tables",
|
| 261 |
+
"outputs": [],
|
| 262 |
+
"params": [
|
| 263 |
+
{
|
| 264 |
+
"default": 100,
|
| 265 |
+
"name": "limit",
|
| 266 |
+
"type": {
|
| 267 |
+
"type": "<class 'int'>"
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
],
|
| 271 |
+
"type": "table_view"
|
| 272 |
+
},
|
| 273 |
+
"params": {
|
| 274 |
+
"limit": 100.0
|
| 275 |
+
},
|
| 276 |
+
"status": "done",
|
| 277 |
+
"title": "View tables"
|
| 278 |
+
},
|
| 279 |
+
"dragHandle": ".bg-primary",
|
| 280 |
+
"height": 215.0,
|
| 281 |
+
"id": "View tables 2",
|
| 282 |
+
"position": {
|
| 283 |
+
"x": 480.0,
|
| 284 |
+
"y": 191.0
|
| 285 |
+
},
|
| 286 |
+
"type": "table_view",
|
| 287 |
+
"width": 225.0
|
| 288 |
+
}
|
| 289 |
+
]
|
| 290 |
+
}
|
examples/multi_output_demo.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lynxkite.core.ops import op
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@op("LynxKite Graph Analytics", "Multi-output example", outputs=["one", "two"])
|
| 6 |
+
def multi_output(*, a_limit=4, b_limit=10):
|
| 7 |
+
"""
|
| 8 |
+
Returns two outputs. Also demonstrates Numpy-style docstrings.
|
| 9 |
+
|
| 10 |
+
Parameters
|
| 11 |
+
----------
|
| 12 |
+
a_limit : int
|
| 13 |
+
Number of elements in output "one".
|
| 14 |
+
b_limit : int
|
| 15 |
+
Number of elements in output "two".
|
| 16 |
+
|
| 17 |
+
Returns
|
| 18 |
+
-------
|
| 19 |
+
A dict with two DataFrames in it.
|
| 20 |
+
"""
|
| 21 |
+
return {
|
| 22 |
+
"one": pd.DataFrame({"a": range(a_limit)}),
|
| 23 |
+
"two": pd.DataFrame({"b": range(b_limit)}),
|
| 24 |
+
}
|