neuronum 1.4.0__py3-none-any.whl → 1.4.2__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.
Potentially problematic release.
This version of neuronum might be problematic. Click here for more details.
- neuronum/neuronum.py +398 -56
- neuronum-1.4.2.dist-info/METADATA +317 -0
- neuronum-1.4.2.dist-info/RECORD +7 -0
- neuronum-1.4.0.dist-info/METADATA +0 -186
- neuronum-1.4.0.dist-info/RECORD +0 -7
- {neuronum-1.4.0.dist-info → neuronum-1.4.2.dist-info}/LICENSE +0 -0
- {neuronum-1.4.0.dist-info → neuronum-1.4.2.dist-info}/WHEEL +0 -0
- {neuronum-1.4.0.dist-info → neuronum-1.4.2.dist-info}/top_level.txt +0 -0
neuronum/neuronum.py
CHANGED
|
@@ -5,7 +5,6 @@ import ssl
|
|
|
5
5
|
from websocket import create_connection
|
|
6
6
|
import json
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
class Cell:
|
|
10
9
|
def __init__(self, host: str, password: str, network: str, synapse: str):
|
|
11
10
|
self.host = host
|
|
@@ -30,12 +29,63 @@ class Cell:
|
|
|
30
29
|
self.sock.sendall(credentials.encode('utf-8'))
|
|
31
30
|
|
|
32
31
|
response = self.sock.recv(1024).decode('utf-8')
|
|
33
|
-
print(response)
|
|
34
32
|
return "Authentication successful" in response
|
|
35
33
|
|
|
36
34
|
|
|
37
|
-
def
|
|
38
|
-
url = f"https://{self.network}/
|
|
35
|
+
def create_tx(self, descr: str, key_values: dict, ctx: str, label: str, partners: list):
|
|
36
|
+
url = f"https://{self.network}/api/create_tx"
|
|
37
|
+
|
|
38
|
+
TX = {
|
|
39
|
+
"descr": descr,
|
|
40
|
+
"key_values": key_values,
|
|
41
|
+
"ctx": ctx,
|
|
42
|
+
"label": label,
|
|
43
|
+
"partners": partners,
|
|
44
|
+
"cell": self.to_dict()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try:
|
|
48
|
+
response = requests.post(
|
|
49
|
+
url,
|
|
50
|
+
json=TX,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
response.raise_for_status()
|
|
54
|
+
|
|
55
|
+
return response.json()["txID"]
|
|
56
|
+
|
|
57
|
+
except requests.exceptions.RequestException as e:
|
|
58
|
+
print(f"Error sending request: {e}")
|
|
59
|
+
except Exception as e:
|
|
60
|
+
print(f"Unexpected error: {e}")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def delete_tx(self, txID: str):
|
|
64
|
+
url = f"https://{self.network}/api/delete_tx"
|
|
65
|
+
|
|
66
|
+
TX = {
|
|
67
|
+
"txID": txID,
|
|
68
|
+
"cell": self.to_dict()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
response = requests.post(
|
|
73
|
+
url,
|
|
74
|
+
json=TX,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
response.raise_for_status()
|
|
78
|
+
|
|
79
|
+
print(f"Response from Neuronum: {response.json()}")
|
|
80
|
+
|
|
81
|
+
except requests.exceptions.RequestException as e:
|
|
82
|
+
print(f"Error sending request: {e}")
|
|
83
|
+
except Exception as e:
|
|
84
|
+
print(f"Unexpected error: {e}")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def activate_tx(self, txID: str, data: dict):
|
|
88
|
+
url = f"https://{self.network}/api/activate_tx/{txID}"
|
|
39
89
|
|
|
40
90
|
TX = {
|
|
41
91
|
"data": data,
|
|
@@ -58,12 +108,115 @@ class Cell:
|
|
|
58
108
|
print(f"Unexpected error: {e}")
|
|
59
109
|
|
|
60
110
|
|
|
111
|
+
def create_ctx(self, descr: str, partners: list):
|
|
112
|
+
url = f"https://{self.network}/api/create_ctx"
|
|
113
|
+
|
|
114
|
+
CTX = {
|
|
115
|
+
"descr": descr,
|
|
116
|
+
"partners": partners,
|
|
117
|
+
"cell": self.to_dict()
|
|
118
|
+
}
|
|
61
119
|
|
|
62
|
-
|
|
63
|
-
|
|
120
|
+
try:
|
|
121
|
+
response = requests.post(
|
|
122
|
+
url,
|
|
123
|
+
json=CTX,
|
|
124
|
+
)
|
|
64
125
|
|
|
65
|
-
|
|
66
|
-
|
|
126
|
+
response.raise_for_status()
|
|
127
|
+
|
|
128
|
+
return response.json()["ctxID"]
|
|
129
|
+
|
|
130
|
+
except requests.exceptions.RequestException as e:
|
|
131
|
+
print(f"Error sending request: {e}")
|
|
132
|
+
except Exception as e:
|
|
133
|
+
print(f"Unexpected error: {e}")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def delete_ctx(self, ctxID: str):
|
|
137
|
+
url = f"https://{self.network}/api/delete_ctx"
|
|
138
|
+
|
|
139
|
+
CTX = {
|
|
140
|
+
"ctxID": ctxID,
|
|
141
|
+
"cell": self.to_dict()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
response = requests.post(
|
|
146
|
+
url,
|
|
147
|
+
json=CTX,
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
response.raise_for_status()
|
|
151
|
+
|
|
152
|
+
print(f"Response from Neuronum: {response.json()}")
|
|
153
|
+
|
|
154
|
+
except requests.exceptions.RequestException as e:
|
|
155
|
+
print(f"Error sending request: {e}")
|
|
156
|
+
except Exception as e:
|
|
157
|
+
print(f"Unexpected error: {e}")
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def create_stx(self, descr: str, partners: list):
|
|
161
|
+
url = f"https://{self.network}/api/create_stx"
|
|
162
|
+
|
|
163
|
+
STX = {
|
|
164
|
+
"descr": descr,
|
|
165
|
+
"partners": partners,
|
|
166
|
+
"cell": self.to_dict()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
try:
|
|
170
|
+
response = requests.post(
|
|
171
|
+
url,
|
|
172
|
+
json=STX,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
response.raise_for_status()["stxID"]
|
|
176
|
+
|
|
177
|
+
return response.json()
|
|
178
|
+
|
|
179
|
+
except requests.exceptions.RequestException as e:
|
|
180
|
+
print(f"Error sending request: {e}")
|
|
181
|
+
except Exception as e:
|
|
182
|
+
print(f"Unexpected error: {e}")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def delete_stx(self, stxID: str):
|
|
186
|
+
url = f"https://{self.network}/api/delete_stx"
|
|
187
|
+
|
|
188
|
+
STX = {
|
|
189
|
+
"stxID": stxID,
|
|
190
|
+
"cell": self.to_dict()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try:
|
|
194
|
+
response = requests.post(
|
|
195
|
+
url,
|
|
196
|
+
json=STX,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
response.raise_for_status()
|
|
200
|
+
|
|
201
|
+
print(f"Response from Neuronum: {response.json()}")
|
|
202
|
+
|
|
203
|
+
except requests.exceptions.RequestException as e:
|
|
204
|
+
print(f"Error sending request: {e}")
|
|
205
|
+
except Exception as e:
|
|
206
|
+
print(f"Unexpected error: {e}")
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def register_node(self, descr: str, mode: str, stx: str):
|
|
210
|
+
if mode == "public":
|
|
211
|
+
url = f"https://{self.network}/api/register_node/public"
|
|
212
|
+
elif mode == "private":
|
|
213
|
+
url = f"https://{self.network}/api/register_node/private"
|
|
214
|
+
else:
|
|
215
|
+
return {"error": "Invalid mode", "message": "Mode has to be 'public' or 'private'"}
|
|
216
|
+
|
|
217
|
+
node_data = {
|
|
218
|
+
"descr": descr,
|
|
219
|
+
"mode": mode,
|
|
67
220
|
"stream": stx,
|
|
68
221
|
"cell": self.to_dict()
|
|
69
222
|
}
|
|
@@ -71,22 +224,230 @@ class Cell:
|
|
|
71
224
|
try:
|
|
72
225
|
response = requests.post(
|
|
73
226
|
url,
|
|
74
|
-
json=
|
|
227
|
+
json=node_data,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
response.raise_for_status()
|
|
231
|
+
|
|
232
|
+
return response.json()["nodeID"]
|
|
233
|
+
|
|
234
|
+
except requests.exceptions.RequestException as e:
|
|
235
|
+
print(f"Error sending request: {e}")
|
|
236
|
+
except Exception as e:
|
|
237
|
+
print(f"Unexpected error: {e}")
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def delete_node(self, nodeID: str):
|
|
241
|
+
url = f"https://{self.network}/api/delete_node"
|
|
242
|
+
|
|
243
|
+
delete_node = {
|
|
244
|
+
"nodeID": nodeID,
|
|
245
|
+
"cell": self.to_dict()
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
try:
|
|
249
|
+
response = requests.post(
|
|
250
|
+
url,
|
|
251
|
+
json=delete_node,
|
|
75
252
|
)
|
|
76
253
|
|
|
77
254
|
response.raise_for_status()
|
|
255
|
+
print(response.json())
|
|
256
|
+
|
|
257
|
+
except requests.exceptions.RequestException as e:
|
|
258
|
+
print(f"Error sending request: {e}")
|
|
259
|
+
except Exception as e:
|
|
260
|
+
print(f"Unexpected error: {e}")
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def sign_contract(self, contractID: str):
|
|
264
|
+
full_url = f"https://{self.network}/api/sign_contract"
|
|
265
|
+
|
|
266
|
+
sign_contract = {
|
|
267
|
+
"contractID": contractID,
|
|
268
|
+
"cell": self.to_dict()
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try:
|
|
272
|
+
response = requests.post(full_url, json=sign_contract)
|
|
273
|
+
response.raise_for_status()
|
|
274
|
+
return response.json()["token"]
|
|
275
|
+
except requests.exceptions.RequestException as e:
|
|
276
|
+
print(f"Error sending request: {e}")
|
|
277
|
+
except Exception as e:
|
|
278
|
+
print(f"Unexpected error: {e}")
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def validate_token(self, token: str, cp: str, contractID: str):
|
|
282
|
+
full_url = f"https://{self.network}/api/validate_token"
|
|
283
|
+
|
|
284
|
+
validate = {
|
|
285
|
+
"token": token,
|
|
286
|
+
"cp": cp,
|
|
287
|
+
"contractID": contractID,
|
|
288
|
+
"cell": self.to_dict()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
try:
|
|
292
|
+
response = requests.post(full_url, json=validate)
|
|
293
|
+
response.raise_for_status()
|
|
294
|
+
return response.json()["validity"]
|
|
295
|
+
except requests.exceptions.RequestException as e:
|
|
296
|
+
print(f"Error sending request: {e}")
|
|
297
|
+
except Exception as e:
|
|
298
|
+
print(f"Unexpected error: {e}")
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def request_token(self, cp: str, contractID: str):
|
|
302
|
+
full_url = f"https://{self.network}/api/request_token"
|
|
303
|
+
|
|
304
|
+
request_token = {
|
|
305
|
+
"cp": cp,
|
|
306
|
+
"contractID": contractID,
|
|
307
|
+
"cell": self.to_dict()
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
try:
|
|
311
|
+
response = requests.post(full_url, json=request_token)
|
|
312
|
+
response.raise_for_status()
|
|
313
|
+
print(response.json())
|
|
314
|
+
except requests.exceptions.RequestException as e:
|
|
315
|
+
print(f"Error sending request: {e}")
|
|
316
|
+
except Exception as e:
|
|
317
|
+
print(f"Unexpected error: {e}")
|
|
78
318
|
|
|
319
|
+
|
|
320
|
+
def present_token(self, token: str, cp: str, contractID: str):
|
|
321
|
+
full_url = f"https://{self.network}/api/present_token"
|
|
322
|
+
|
|
323
|
+
present_token = {
|
|
324
|
+
"token": token,
|
|
325
|
+
"cp": cp,
|
|
326
|
+
"contractID": contractID,
|
|
327
|
+
"cell": self.to_dict()
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
try:
|
|
331
|
+
response = requests.post(full_url, json=present_token)
|
|
332
|
+
response.raise_for_status()
|
|
333
|
+
print(response.json())
|
|
334
|
+
except requests.exceptions.RequestException as e:
|
|
335
|
+
print(f"Error sending request: {e}")
|
|
336
|
+
except Exception as e:
|
|
337
|
+
print(f"Unexpected error: {e}")
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def create_contract(self, descr: str, details: dict, partners: list):
|
|
341
|
+
full_url = f"https://{self.network}/api/create_contract"
|
|
342
|
+
|
|
343
|
+
create_contract = {
|
|
344
|
+
"cell": self.to_dict(),
|
|
345
|
+
"descr": descr,
|
|
346
|
+
"details": details,
|
|
347
|
+
"partners": partners
|
|
348
|
+
}
|
|
349
|
+
try:
|
|
350
|
+
response = requests.post(full_url, json=create_contract)
|
|
351
|
+
response.raise_for_status()
|
|
352
|
+
return response.json()["contractID"]
|
|
353
|
+
except requests.exceptions.RequestException as e:
|
|
354
|
+
print(f"Error sending request: {e}")
|
|
355
|
+
except Exception as e:
|
|
356
|
+
print(f"Unexpected error: {e}")
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def delete_contract(self, contractID: str):
|
|
360
|
+
full_url = f"https://{self.network}/api/delete_contract"
|
|
361
|
+
|
|
362
|
+
request = {
|
|
363
|
+
"cell": self.to_dict(),
|
|
364
|
+
"contractID": contractID
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
try:
|
|
368
|
+
response = requests.post(full_url, json=request)
|
|
369
|
+
response.raise_for_status()
|
|
79
370
|
print(f"Response from Neuronum: {response.json()}")
|
|
371
|
+
except requests.exceptions.RequestException as e:
|
|
372
|
+
print(f"Error sending request: {e}")
|
|
373
|
+
except Exception as e:
|
|
374
|
+
print(f"Unexpected error: {e}")
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def list_contracts(self, cp: str):
|
|
378
|
+
full_url = f"https://{self.network}/api/list_contracts"
|
|
379
|
+
|
|
380
|
+
list_contracts = {
|
|
381
|
+
"cell": self.to_dict(),
|
|
382
|
+
"cp": cp
|
|
383
|
+
}
|
|
80
384
|
|
|
385
|
+
try:
|
|
386
|
+
response = requests.post(full_url, json=list_contracts)
|
|
387
|
+
response.raise_for_status()
|
|
388
|
+
return response.json()
|
|
81
389
|
except requests.exceptions.RequestException as e:
|
|
82
390
|
print(f"Error sending request: {e}")
|
|
83
391
|
except Exception as e:
|
|
84
392
|
print(f"Unexpected error: {e}")
|
|
85
393
|
|
|
86
394
|
|
|
395
|
+
def list_tx(self, cp: str):
|
|
396
|
+
full_url = f"https://{self.network}/api/list_tx"
|
|
397
|
+
|
|
398
|
+
list_tx = {
|
|
399
|
+
"cell": self.to_dict(),
|
|
400
|
+
"cp": cp
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
try:
|
|
404
|
+
response = requests.post(full_url, json=list_tx)
|
|
405
|
+
response.raise_for_status()
|
|
406
|
+
return response.json()
|
|
407
|
+
except requests.exceptions.RequestException as e:
|
|
408
|
+
print(f"Error sending request: {e}")
|
|
409
|
+
except Exception as e:
|
|
410
|
+
print(f"Unexpected error: {e}")
|
|
411
|
+
|
|
87
412
|
|
|
88
|
-
def
|
|
89
|
-
|
|
413
|
+
def list_ctx(self, cp: str):
|
|
414
|
+
full_url = f"https://{self.network}/api/list_ctx"
|
|
415
|
+
|
|
416
|
+
list_ctx = {
|
|
417
|
+
"cell": self.to_dict(),
|
|
418
|
+
"cp": cp
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
try:
|
|
422
|
+
response = requests.post(full_url, json=list_ctx)
|
|
423
|
+
response.raise_for_status()
|
|
424
|
+
return response.json()
|
|
425
|
+
except requests.exceptions.RequestException as e:
|
|
426
|
+
print(f"Error sending request: {e}")
|
|
427
|
+
except Exception as e:
|
|
428
|
+
print(f"Unexpected error: {e}")
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def list_stx(self, cp: str):
|
|
432
|
+
full_url = f"https://{self.network}/api/list_stx"
|
|
433
|
+
|
|
434
|
+
list_stx = {
|
|
435
|
+
"cell": self.to_dict(),
|
|
436
|
+
"cp": cp
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
try:
|
|
440
|
+
response = requests.post(full_url, json=list_stx)
|
|
441
|
+
response.raise_for_status()
|
|
442
|
+
return response.json()
|
|
443
|
+
except requests.exceptions.RequestException as e:
|
|
444
|
+
print(f"Error sending request: {e}")
|
|
445
|
+
except Exception as e:
|
|
446
|
+
print(f"Unexpected error: {e}")
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def connect(self):
|
|
450
|
+
url = f"https://{self.network}/api/connect"
|
|
90
451
|
|
|
91
452
|
test = {
|
|
92
453
|
"cell": self.to_dict()
|
|
@@ -95,7 +456,7 @@ class Cell:
|
|
|
95
456
|
try:
|
|
96
457
|
response = requests.post(url, json=test)
|
|
97
458
|
response.raise_for_status()
|
|
98
|
-
print(response.json())
|
|
459
|
+
print(response.json()["connection"])
|
|
99
460
|
except requests.exceptions.RequestException as e:
|
|
100
461
|
print(f"Error sending request: {e}")
|
|
101
462
|
except Exception as e:
|
|
@@ -104,9 +465,9 @@ class Cell:
|
|
|
104
465
|
|
|
105
466
|
def store(self, label: str, data: dict, ctx: Optional[str] = None):
|
|
106
467
|
if ctx:
|
|
107
|
-
full_url = f"https://{self.network}/
|
|
468
|
+
full_url = f"https://{self.network}/api/store_in_ctx/{ctx}"
|
|
108
469
|
else:
|
|
109
|
-
full_url = f"https://{self.network}/store"
|
|
470
|
+
full_url = f"https://{self.network}/api/store"
|
|
110
471
|
|
|
111
472
|
store = {
|
|
112
473
|
"label": label,
|
|
@@ -127,11 +488,9 @@ class Cell:
|
|
|
127
488
|
|
|
128
489
|
def load(self, label: str, ctx: Optional[str] = None):
|
|
129
490
|
if ctx:
|
|
130
|
-
full_url = f"https://{self.network}/
|
|
491
|
+
full_url = f"https://{self.network}/api/load_from_ctx/{ctx}"
|
|
131
492
|
else:
|
|
132
|
-
full_url = f"https://{self.network}/load"
|
|
133
|
-
|
|
134
|
-
print(f"Full URL: {full_url}")
|
|
493
|
+
full_url = f"https://{self.network}/api/load"
|
|
135
494
|
|
|
136
495
|
load = {
|
|
137
496
|
"label": label,
|
|
@@ -151,11 +510,9 @@ class Cell:
|
|
|
151
510
|
|
|
152
511
|
def delete(self, label: str, ctx: Optional[str] = None):
|
|
153
512
|
if ctx:
|
|
154
|
-
full_url = f"https://{self.network}/
|
|
513
|
+
full_url = f"https://{self.network}/api/delete_from_ctx/{ctx}"
|
|
155
514
|
else:
|
|
156
|
-
full_url = f"https://{self.network}/delete"
|
|
157
|
-
|
|
158
|
-
print(f"Full URL: {full_url}")
|
|
515
|
+
full_url = f"https://{self.network}/api/delete"
|
|
159
516
|
|
|
160
517
|
delete = {
|
|
161
518
|
"label": label,
|
|
@@ -174,11 +531,9 @@ class Cell:
|
|
|
174
531
|
|
|
175
532
|
def clear(self, ctx: Optional[str] = None):
|
|
176
533
|
if ctx:
|
|
177
|
-
full_url = f"https://{self.network}/clear_ctx/{ctx}"
|
|
534
|
+
full_url = f"https://{self.network}/api/clear_ctx/{ctx}"
|
|
178
535
|
else:
|
|
179
|
-
full_url = f"https://{self.network}/clear"
|
|
180
|
-
|
|
181
|
-
print(f"Full URL: {full_url}")
|
|
536
|
+
full_url = f"https://{self.network}/api/clear"
|
|
182
537
|
|
|
183
538
|
clear = {
|
|
184
539
|
"cell": self.to_dict()
|
|
@@ -234,48 +589,35 @@ class Cell:
|
|
|
234
589
|
"password": self.password,
|
|
235
590
|
"synapse": self.synapse,
|
|
236
591
|
}
|
|
237
|
-
ws = None
|
|
238
592
|
|
|
239
593
|
try:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
ws.settimeout(1)
|
|
244
|
-
ws.send(json.dumps(auth))
|
|
245
|
-
print("Stream connection set...")
|
|
594
|
+
ws = create_connection(f"wss://{self.network}/sync/{stx}")
|
|
595
|
+
ws.send(json.dumps(auth))
|
|
596
|
+
print("Stream connection set...")
|
|
246
597
|
|
|
598
|
+
try:
|
|
599
|
+
while True:
|
|
247
600
|
try:
|
|
248
601
|
raw_operation = ws.recv()
|
|
249
602
|
operation = json.loads(raw_operation)
|
|
250
603
|
print("Listening to Stream...")
|
|
251
604
|
yield operation
|
|
252
605
|
|
|
253
|
-
ws.settimeout(None)
|
|
254
|
-
|
|
255
|
-
while True:
|
|
256
|
-
raw_operation = ws.recv()
|
|
257
|
-
operation = json.loads(raw_operation)
|
|
258
|
-
yield operation
|
|
259
606
|
except socket.timeout:
|
|
260
|
-
print("No initial data received.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
finally:
|
|
272
|
-
if ws:
|
|
273
|
-
ws.close()
|
|
274
|
-
print("Connection closed.")
|
|
607
|
+
print("No initial data received. Continuing to listen...")
|
|
608
|
+
continue
|
|
609
|
+
|
|
610
|
+
except KeyboardInterrupt:
|
|
611
|
+
print("Stream-Synchronization ended!")
|
|
612
|
+
except Exception as e:
|
|
613
|
+
print(f"Error: {e}")
|
|
614
|
+
finally:
|
|
615
|
+
ws.close()
|
|
616
|
+
print("Connection closed.")
|
|
617
|
+
|
|
275
618
|
except KeyboardInterrupt:
|
|
276
619
|
print("Stream-Synchronization ended!")
|
|
277
|
-
|
|
278
|
-
ws.close()
|
|
620
|
+
ws.close()
|
|
279
621
|
print("Connection closed. Goodbye!")
|
|
280
622
|
|
|
281
623
|
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: neuronum
|
|
3
|
+
Version: 1.4.2
|
|
4
|
+
Summary: Interact with the Neuronum Network to build, connect & automate real-time data streams
|
|
5
|
+
Home-page: https://neuronum.net
|
|
6
|
+
Author: Neuronum Cybernetics
|
|
7
|
+
Author-email: welcome@neuronum.net
|
|
8
|
+
Project-URL: GitHub, https://github.com/neuronumcybernetics/neuronum
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.6
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: requests
|
|
16
|
+
Requires-Dist: websocket-client
|
|
17
|
+
Requires-Dist: iota-sdk
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
[](https://neuronum.net)
|
|
22
|
+
[](https://github.com/neuronumcybernetics/neuronum)
|
|
23
|
+
[](https://www.youtube.com/@neuronumnet)
|
|
24
|
+
|
|
25
|
+
`Neuronum` is a cybernetic framework enabling businesses to build interconnected networks of Hardware and Software components
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
- **Cell**: Identity to connect and interact with the Neuronum Network
|
|
29
|
+
- **Transmitters (TX)**: Automate economic data transfer and storage
|
|
30
|
+
- **Circuits (CTX)**: Store data in a Key-Value-Label database
|
|
31
|
+
- **Streams (STX)**: Stream, synchronize and control data in real time
|
|
32
|
+
- **Nodes**: Hard-/Software components participating in the Network ecosystem
|
|
33
|
+
- **Contracts/Tokens**: Automate Contract-based authorization between Nodes
|
|
34
|
+
|
|
35
|
+
## Getting Started
|
|
36
|
+
To interact with the Network you will need to create a Neuronum Cell.
|
|
37
|
+
Create your Cell: [Create Cell](https://neuronum.net/createcell)
|
|
38
|
+
|
|
39
|
+
Start with installing the Neuronum library using pip:
|
|
40
|
+
```python
|
|
41
|
+
pip install neuronum
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Configure and test Cell connection:
|
|
45
|
+
```python
|
|
46
|
+
import neuronum
|
|
47
|
+
|
|
48
|
+
cell = neuronum.Cell(
|
|
49
|
+
host="host::cell", # specify your cell host
|
|
50
|
+
password="your_password", # enter your cell password
|
|
51
|
+
network="neuronum.net", # choose network
|
|
52
|
+
synapse="your_synapse" # provide the synapse (token)
|
|
53
|
+
)
|
|
54
|
+
cell.connect()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Transmitters (TX)
|
|
58
|
+
Transmitters (TX) are used to create predefined templates to receive and send data in a standardized format. Data send with TX is always and automatically stored in a predefined Circuit (CTX)
|
|
59
|
+
|
|
60
|
+
Create Transmitter (TX):
|
|
61
|
+
```python
|
|
62
|
+
descr = "Test Transmitter" # short description (max 25 characters)
|
|
63
|
+
key_values = { # predefined keys with example values
|
|
64
|
+
"key1": "value1",
|
|
65
|
+
"key2": "value2",
|
|
66
|
+
"key3": "value3",
|
|
67
|
+
}
|
|
68
|
+
ctx = "id::ctx" # target Circuit (CTX)
|
|
69
|
+
label = "key1:key2" # label data sent with the TX
|
|
70
|
+
partners = ["id::cell", "id::cell"] # authorized cells
|
|
71
|
+
txID = cell.create_tx(decr, key_values, ctx, label, partners)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Activate Transmitter (TX):
|
|
75
|
+
```python
|
|
76
|
+
TX = "id::tx" # specify the Transmitter (TX)
|
|
77
|
+
data = { # enter key values
|
|
78
|
+
"key1": "value1",
|
|
79
|
+
"key2": "value2",
|
|
80
|
+
"key3": "value3",
|
|
81
|
+
}
|
|
82
|
+
cell.activate_tx(TX, data)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Delete Transmitter (TX):
|
|
86
|
+
```python
|
|
87
|
+
TX = "id::tx" # specify the Transmitter (TX)
|
|
88
|
+
cell.delete_tx(TX)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
List Transmitter (TX) from cell:
|
|
92
|
+
```python
|
|
93
|
+
cell = "id::cell" # specify cell
|
|
94
|
+
txList = cell.list_tx(cell)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Circuits (CTX)
|
|
98
|
+
Circuits (CTX) store and organize data sent via Transmitters (TX) using a Key-Value-Label system, ensuring efficient retrieval and management within the Neuronum network
|
|
99
|
+
|
|
100
|
+
Create Circuit (CTX):
|
|
101
|
+
```python
|
|
102
|
+
descr = "Test Circuit" # short description of the circuit (max 25 characters)
|
|
103
|
+
partners = ["id::cell", "id::cell"] # authorized cells
|
|
104
|
+
ctxID = cell.create_ctx(decr, partners)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Store data on your private Circuit (CTX):
|
|
108
|
+
```python
|
|
109
|
+
label = "your_label" # define a unique label (tag)
|
|
110
|
+
data = { # store data as key-value pairs
|
|
111
|
+
"key1": "value1",
|
|
112
|
+
"key2": "value2",
|
|
113
|
+
"key3": "value3",
|
|
114
|
+
}
|
|
115
|
+
cell.store(label, data)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Store data on a public Circuit (CTX):
|
|
119
|
+
```python
|
|
120
|
+
CTX = "id::ctx" # specify the Circuit (CTX
|
|
121
|
+
label = "your_label" # define a unique label (tag)
|
|
122
|
+
data = { # store data as key-value pairs
|
|
123
|
+
"key1": "value1",
|
|
124
|
+
"key2": "value2",
|
|
125
|
+
"key3": "value3",
|
|
126
|
+
}
|
|
127
|
+
cell.store(label, data, CTX)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Load data from your private Circuit (CTX):
|
|
131
|
+
```python
|
|
132
|
+
label = "your_label" # load data by label
|
|
133
|
+
data = cell.load(label)
|
|
134
|
+
key1 = data["key1"] # get the data from the keys
|
|
135
|
+
key2 = data["key2"]
|
|
136
|
+
key3 = data["key3"]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Load data from a public Circuit (CTX):
|
|
140
|
+
```python
|
|
141
|
+
CTX = "id::ctx" # specify the CTX
|
|
142
|
+
label = "your_label" # load data by label
|
|
143
|
+
data = cell.load(label, CTX)
|
|
144
|
+
key1 = data["key1"] # get the data from the keys
|
|
145
|
+
key2 = data["key2"]
|
|
146
|
+
key3 = data["key3"]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Delete data from your private Circuit (CTX):
|
|
150
|
+
```python
|
|
151
|
+
label = "your_label" # delete data by label
|
|
152
|
+
cell.delete(label)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Delete data from a public Circuit (CTX):
|
|
156
|
+
```python
|
|
157
|
+
CTX = "id::ctx" # specify the CTX
|
|
158
|
+
label = "your_label" # delete data by label
|
|
159
|
+
cell.delete(label, CTX)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Empty your private Circuit (CTX):
|
|
163
|
+
```python
|
|
164
|
+
cell.clear()
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Empty a Circuit (CTX):
|
|
168
|
+
```python
|
|
169
|
+
CTX = "id::ctx" # specify the CTX
|
|
170
|
+
cell.clear(CTX)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Delete Circuit (CTX):
|
|
174
|
+
```python
|
|
175
|
+
CTX = "id::ctx" # specify the Circuit (CTX)
|
|
176
|
+
cell.delete_ctx(CTX)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
List Circuits (CTX) from cell:
|
|
180
|
+
```python
|
|
181
|
+
cell = "id::cell" # specify cell
|
|
182
|
+
ctxList = cell.list_ctx(cell)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Streams (STX)
|
|
186
|
+
Streams (STX) facilitate real-time data synchronization and interaction, ensuring seamless connectivity between all Nodes in the Neuronum network
|
|
187
|
+
|
|
188
|
+
Create Stream (CTX):
|
|
189
|
+
```python
|
|
190
|
+
descr = "Test Stream" # short description (max 25 characters)
|
|
191
|
+
partners = ["id::cell", "id::cell"] # authorized cells
|
|
192
|
+
stxID = cell.create_stx(decr, partners)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Stream data to your private Stream (STX):
|
|
196
|
+
```python
|
|
197
|
+
label = "your_label" # label your data
|
|
198
|
+
data = { # define data package (key-values)
|
|
199
|
+
"key1": "value1",
|
|
200
|
+
"key2": "value2",
|
|
201
|
+
"key3": "value3",
|
|
202
|
+
}
|
|
203
|
+
cell.stream(label, data)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Stream data to a public Stream (STX):
|
|
207
|
+
```python
|
|
208
|
+
STX = "id::stx" # specify the STX
|
|
209
|
+
label = "your_label" # label your data
|
|
210
|
+
data = { # define data package (key-values)
|
|
211
|
+
"key1": "value1",
|
|
212
|
+
"key2": "value2",
|
|
213
|
+
"key3": "value3",
|
|
214
|
+
}
|
|
215
|
+
cell.stream(label, data, STX)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Sync data from your private Stream (STX):
|
|
219
|
+
```python
|
|
220
|
+
stream = cell.sync() # retrieve stream data
|
|
221
|
+
for operation in stream: # iterate through each operation
|
|
222
|
+
label = operation.get("label") # get the operation details
|
|
223
|
+
key1 = operation.get("data").get("key1")
|
|
224
|
+
key2 = operation.get("data").get("key2")
|
|
225
|
+
key3 = operation.get("data").get("key3")
|
|
226
|
+
ts = operation.get("time")
|
|
227
|
+
stxID = operation.get("stxID")
|
|
228
|
+
operator = operation.get("operator")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Sync data from a public Stream (STX):
|
|
232
|
+
```python
|
|
233
|
+
STX = "id::stx" # specify the STX
|
|
234
|
+
stream = cell.sync(STX) # retrieve stream data
|
|
235
|
+
for operation in stream: # iterate through each operation
|
|
236
|
+
label = operation.get("label") # get the operation details
|
|
237
|
+
key1 = operation.get("data").get("key1")
|
|
238
|
+
key2 = operation.get("data").get("key2")
|
|
239
|
+
key3 = operation.get("data").get("key3")
|
|
240
|
+
ts = operation.get("time")
|
|
241
|
+
stxID = operation.get("stxID")
|
|
242
|
+
operator = operation.get("operator")
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
List Streams (STX) from cell:
|
|
246
|
+
```python
|
|
247
|
+
cell = "id::cell" # specify cell
|
|
248
|
+
stxList = cell.list_stx(cell)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Nodes
|
|
252
|
+
Neuronum Nodes are computing hardware running the Neuronum Client Library, enabling seamless data transmission, synchronization, and facilitating public Stream (STX) access
|
|
253
|
+
|
|
254
|
+
Register a Node with its associated Stream (STX):
|
|
255
|
+
```python
|
|
256
|
+
descr = "node_name" # short description (max 25 characters)
|
|
257
|
+
mode = "public" # set to "public or "private
|
|
258
|
+
STX = "id::stx" # specify the STX
|
|
259
|
+
nodeID = cell.register_node(descr, mode, STX)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Remove a Node:
|
|
263
|
+
```python
|
|
264
|
+
nodeID = "id::node" # get Node by ID
|
|
265
|
+
cell.delete_node(nodeID)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
### Contracts/Tokens
|
|
270
|
+
Contracts define rules for authorization, allowing users to sign and generate unique tokens for secure access
|
|
271
|
+
|
|
272
|
+
Create a Contract:
|
|
273
|
+
```python
|
|
274
|
+
descr = "Test Contract" # short description (max 25 characters)
|
|
275
|
+
details = { # define token details
|
|
276
|
+
"price_in_eur": 10, # token price in EUR
|
|
277
|
+
"max_usage": 10, # max number of uses
|
|
278
|
+
"validity_in_min": 10 # token expiration time (minutes)
|
|
279
|
+
}
|
|
280
|
+
partners = ["id::cell", "id::cell"]
|
|
281
|
+
contractID = cell.create_contract(descr, details, partners)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Sign a Contract:
|
|
285
|
+
```python
|
|
286
|
+
contractID = "id::contract" # specify the contract
|
|
287
|
+
token = cell.sign_contract(contractID)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Request a Token from another Cell to authorize a service:
|
|
291
|
+
```python
|
|
292
|
+
cp = "id::cell" # specify the counterparty cell
|
|
293
|
+
contractID = "id::contract" # specify the contract
|
|
294
|
+
cell.request_token(cp, contractID)
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Present a Token to another Cell to authorize a service:
|
|
298
|
+
```python
|
|
299
|
+
token = "token" # specify the token
|
|
300
|
+
cp = "id::cell" # specify the counterparty cell
|
|
301
|
+
contractID = "id::contract" # specify the contract
|
|
302
|
+
cell.present_token(token, cp, contractID)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Validate a Token to authorize a service:
|
|
306
|
+
```python
|
|
307
|
+
token = "token" # specify the token
|
|
308
|
+
cp = "id::cell" # specify the counterparty cell
|
|
309
|
+
contractID = "id::contract" # specify the contract
|
|
310
|
+
cell.validate_token(token, cp, contractID)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
List Contracts from cell:
|
|
314
|
+
```python
|
|
315
|
+
cell = "id::cell" # specify cell
|
|
316
|
+
contractList = cell.list_contracts(cell)
|
|
317
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
|
|
2
|
+
neuronum/neuronum.py,sha256=Qe8Va5cI5LRFDV0nksedM8HwmbZiTsyNP5QSg9ffFVI,18737
|
|
3
|
+
neuronum-1.4.2.dist-info/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
|
|
4
|
+
neuronum-1.4.2.dist-info/METADATA,sha256=J5B-8ngh_GhQW0829pBx3JHoyKk9J6xa663JqPqPH88,10116
|
|
5
|
+
neuronum-1.4.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
+
neuronum-1.4.2.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
7
|
+
neuronum-1.4.2.dist-info/RECORD,,
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: neuronum
|
|
3
|
-
Version: 1.4.0
|
|
4
|
-
Summary: Interact with the Neuronum Network to build, connect & automate economic data streams
|
|
5
|
-
Home-page: https://neuronum.net
|
|
6
|
-
Author: Neuronum Cybernetics
|
|
7
|
-
Author-email: welcome@neuronum.net
|
|
8
|
-
Project-URL: GitHub, https://github.com/neuronumcybernetics/neuronum
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.6
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: requests
|
|
16
|
-
Requires-Dist: websocket-client
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
[](https://neuronum.net)
|
|
21
|
-
[](https://github.com/neuronumcybernetics/neuronum)
|
|
22
|
-
[](https://www.youtube.com/@neuronumnet)
|
|
23
|
-
|
|
24
|
-
Interact with the `Neuronum Network` to build, connect & automate economic data streams.
|
|
25
|
-
|
|
26
|
-
## Cell Features
|
|
27
|
-
- **Transmitters (TX)**: Automate economic data transfer + Circuits Integration
|
|
28
|
-
- **Circuits (CTX)**: A simple Key-Value-Label database to store economic data
|
|
29
|
-
- **Streams (STX)**: Stream, synchronize and control data in real time
|
|
30
|
-
- **Nodes**: Register Nodes actively running the Neuronum library
|
|
31
|
-
|
|
32
|
-
## Getting Started
|
|
33
|
-
Create your Neuronum Cell: [Create Cell](https://neuronum.net/createcell)
|
|
34
|
-
|
|
35
|
-
Install the Neuronum library using pip:
|
|
36
|
-
```bash
|
|
37
|
-
pip install neuronum
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Set and test Cell connection:
|
|
41
|
-
```bash
|
|
42
|
-
import neuronum
|
|
43
|
-
|
|
44
|
-
cell = neuronum.Cell(
|
|
45
|
-
host="host::cell",
|
|
46
|
-
password="your_password",
|
|
47
|
-
network="neuronum.net",
|
|
48
|
-
synapse="your_synapse"
|
|
49
|
-
)
|
|
50
|
-
cell.test_connection()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Transmitters (TX)
|
|
54
|
-
Activate Transmitter (TX):
|
|
55
|
-
```bash
|
|
56
|
-
TX = "id::tx"
|
|
57
|
-
data = {
|
|
58
|
-
"key1": "value1",
|
|
59
|
-
"key2": "value2",
|
|
60
|
-
"key3": "value3",
|
|
61
|
-
}
|
|
62
|
-
cell.activate(TX, data)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Circuits (CTX)
|
|
66
|
-
Store data on your private Circuit (CTX):
|
|
67
|
-
```bash
|
|
68
|
-
label = "your_label"
|
|
69
|
-
data = {
|
|
70
|
-
"key1": "value1",
|
|
71
|
-
"key2": "value2",
|
|
72
|
-
"key3": "value3",
|
|
73
|
-
}
|
|
74
|
-
cell.store(label, data)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Store data on a public Circuit (CTX):
|
|
78
|
-
```bash
|
|
79
|
-
CTX = "id::ctx"
|
|
80
|
-
label = "your_label"
|
|
81
|
-
data = {
|
|
82
|
-
"key1": "value1",
|
|
83
|
-
"key2": "value2",
|
|
84
|
-
"key3": "value3",
|
|
85
|
-
}
|
|
86
|
-
cell.store(label, data, CTX)
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Load data from your private Circuit (CTX):
|
|
90
|
-
```bash
|
|
91
|
-
label = "your_label"
|
|
92
|
-
data = cell.load(label)
|
|
93
|
-
key1 = data["key1"]
|
|
94
|
-
key2 = data["key2"]
|
|
95
|
-
key3 = data["key3"]
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Load data from a public Circuit (CTX):
|
|
99
|
-
```bash
|
|
100
|
-
CTX = "id::ctx"
|
|
101
|
-
label = "your_label"
|
|
102
|
-
data = cell.load(label, CTX)
|
|
103
|
-
key1 = data["key1"]
|
|
104
|
-
key2 = data["key2"]
|
|
105
|
-
key3 = data["key3"]
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Delete data from your private Circuit (CTX):
|
|
109
|
-
```bash
|
|
110
|
-
label = "your_label"
|
|
111
|
-
data = cell.delete(label)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Delete data from a public Circuit (CTX):
|
|
115
|
-
```bash
|
|
116
|
-
CTX = "id::ctx"
|
|
117
|
-
label = "your_label"
|
|
118
|
-
data = cell.delete(label, CTX)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Empty your private Circuit (CTX):
|
|
122
|
-
```bash
|
|
123
|
-
cell.clear()
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Empty a public Circuit (CTX):
|
|
127
|
-
```bash
|
|
128
|
-
CTX = "id::ctx"
|
|
129
|
-
cell.clear(CTX)
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Streams (STX)
|
|
133
|
-
Stream data to your private Stream (STX):
|
|
134
|
-
```bash
|
|
135
|
-
label = "your_label"
|
|
136
|
-
data = {
|
|
137
|
-
"key1": "value1",
|
|
138
|
-
"key2": "value2",
|
|
139
|
-
"key3": "value3",
|
|
140
|
-
}
|
|
141
|
-
cell.stream(label, data)
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Stream data to a public Stream (STX):
|
|
145
|
-
```bash
|
|
146
|
-
STX = "id::stx"
|
|
147
|
-
label = "your_label"
|
|
148
|
-
data = {
|
|
149
|
-
"key1": "value1",
|
|
150
|
-
"key2": "value2",
|
|
151
|
-
"key3": "value3",
|
|
152
|
-
}
|
|
153
|
-
cell.stream(label, data, STX)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Sync data from your private Stream (STX):
|
|
157
|
-
```bash
|
|
158
|
-
stream = cell.sync()
|
|
159
|
-
for operation in stream:
|
|
160
|
-
label = operation.get("label")
|
|
161
|
-
value = operation.get("data").get("key1")
|
|
162
|
-
ts = operation.get("time")
|
|
163
|
-
stxID = operation.get("stxID")
|
|
164
|
-
operator = operation.get("operator")
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Sync data from a public Stream (STX):
|
|
168
|
-
```bash
|
|
169
|
-
STX = "id::stx"
|
|
170
|
-
stream = cell.sync(STX)
|
|
171
|
-
for operation in stream:
|
|
172
|
-
label = operation.get("label")
|
|
173
|
-
value = operation.get("data").get("key1")
|
|
174
|
-
ts = operation.get("time")
|
|
175
|
-
stxID = operation.get("stxID")
|
|
176
|
-
operator = operation.get("operator")
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Nodes
|
|
180
|
-
Register a Neuronum Node with its associated Stream:
|
|
181
|
-
```bash
|
|
182
|
-
node = "name_your_node"
|
|
183
|
-
STX = "id::stx"
|
|
184
|
-
cell.register(node, STX)
|
|
185
|
-
```
|
|
186
|
-
|
neuronum-1.4.0.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
|
|
2
|
-
neuronum/neuronum.py,sha256=wjFvv8j5aF8vpMy0fEWIJLFWIYo1hzBa8Ml4ANRunSs,8614
|
|
3
|
-
neuronum-1.4.0.dist-info/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
|
|
4
|
-
neuronum-1.4.0.dist-info/METADATA,sha256=eJw381gFqsLBCl4Nzsj6uY7W16phRGrc_FU23--Sl9Y,4338
|
|
5
|
-
neuronum-1.4.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
6
|
-
neuronum-1.4.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
7
|
-
neuronum-1.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|