neuronum 2.0.2__py3-none-any.whl → 2.0.3__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.
- cli/main.py +133 -53
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/METADATA +14 -4
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/RECORD +7 -7
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/WHEEL +0 -0
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/entry_points.txt +0 -0
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/licenses/LICENSE +0 -0
- {neuronum-2.0.2.dist-info → neuronum-2.0.3.dist-info}/top_level.txt +0 -0
cli/main.py
CHANGED
|
@@ -6,8 +6,7 @@ import subprocess
|
|
|
6
6
|
import os
|
|
7
7
|
import neuronum
|
|
8
8
|
import json
|
|
9
|
-
import
|
|
10
|
-
import cellai
|
|
9
|
+
import platform
|
|
11
10
|
|
|
12
11
|
@click.group()
|
|
13
12
|
def cli():
|
|
@@ -245,8 +244,9 @@ def delete_cell():
|
|
|
245
244
|
|
|
246
245
|
|
|
247
246
|
@click.command()
|
|
248
|
-
@click.option('--sync',
|
|
249
|
-
|
|
247
|
+
@click.option('--sync', required=True, nargs=1, help="Stream ID required for sync.")
|
|
248
|
+
@click.option('--stream', required=True, nargs=1, help="Stream ID required for stream.")
|
|
249
|
+
def init_node(sync, stream):
|
|
250
250
|
|
|
251
251
|
node_type = questionary.select(
|
|
252
252
|
"Choose Node type:",
|
|
@@ -255,12 +255,10 @@ def init_node(sync):
|
|
|
255
255
|
|
|
256
256
|
descr = click.prompt("Node description (max. 25 characters)")
|
|
257
257
|
|
|
258
|
-
stream = sync if sync else "n9gW3LxQcecI::stx"
|
|
259
|
-
|
|
260
258
|
credentials_folder_path = Path.home() / ".neuronum"
|
|
261
259
|
env_path = credentials_folder_path / ".env"
|
|
262
260
|
|
|
263
|
-
env_data = {}
|
|
261
|
+
env_data = {}
|
|
264
262
|
|
|
265
263
|
try:
|
|
266
264
|
with open(env_path, "r") as f:
|
|
@@ -280,22 +278,7 @@ def init_node(sync):
|
|
|
280
278
|
click.echo(f"Error reading .env file: {e}")
|
|
281
279
|
return
|
|
282
280
|
|
|
283
|
-
cell = neuronum.Cell(
|
|
284
|
-
host=host,
|
|
285
|
-
password=password,
|
|
286
|
-
network=network,
|
|
287
|
-
synapse=synapse
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
cells = cell.list_cells()
|
|
291
|
-
tx = cell.list_tx()
|
|
292
|
-
ctx = cell.list_ctx()
|
|
293
|
-
stx = cell.list_stx()
|
|
294
|
-
contracts = cell.list_contracts()
|
|
295
|
-
nodes = cell.list_nodes()
|
|
296
|
-
|
|
297
281
|
url = f"https://{network}/api/init_node/{node_type}"
|
|
298
|
-
|
|
299
282
|
node = {"descr": descr, "host": host, "password": password, "synapse": synapse}
|
|
300
283
|
|
|
301
284
|
try:
|
|
@@ -310,37 +293,80 @@ def init_node(sync):
|
|
|
310
293
|
project_path = Path(node_filename)
|
|
311
294
|
project_path.mkdir(exist_ok=True)
|
|
312
295
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
296
|
+
cell = neuronum.Cell(
|
|
297
|
+
host=host,
|
|
298
|
+
password=password,
|
|
299
|
+
network=network,
|
|
300
|
+
synapse=synapse
|
|
301
|
+
)
|
|
318
302
|
|
|
319
|
-
|
|
320
|
-
|
|
303
|
+
cells = cell.list_cells()
|
|
304
|
+
tx = cell.list_tx()
|
|
305
|
+
ctx = cell.list_ctx()
|
|
306
|
+
stx = cell.list_stx()
|
|
307
|
+
contracts = cell.list_contracts()
|
|
308
|
+
nodes = cell.list_nodes()
|
|
321
309
|
|
|
310
|
+
cells_path = project_path / "cells.json"
|
|
322
311
|
tx_path = project_path / "transmitters.json"
|
|
323
|
-
tx_path.write_text(json.dumps(tx, indent=4))
|
|
324
|
-
|
|
325
312
|
ctx_path = project_path / "circuits.json"
|
|
326
|
-
ctx_path.write_text(json.dumps(ctx, indent=4))
|
|
327
|
-
|
|
328
313
|
stx_path = project_path / "streams.json"
|
|
329
|
-
stx_path.write_text(json.dumps(stx, indent=4))
|
|
330
|
-
|
|
331
314
|
contracts_path = project_path / "contracts.json"
|
|
332
|
-
contracts_path.write_text(json.dumps(contracts, indent=4))
|
|
333
|
-
|
|
334
315
|
nodes_path = project_path / "nodes.json"
|
|
316
|
+
|
|
317
|
+
cells_path.write_text(json.dumps(cells, indent=4))
|
|
318
|
+
tx_path.write_text(json.dumps(tx, indent=4))
|
|
319
|
+
ctx_path.write_text(json.dumps(ctx, indent=4))
|
|
320
|
+
stx_path.write_text(json.dumps(stx, indent=4))
|
|
321
|
+
contracts_path.write_text(json.dumps(contracts, indent=4))
|
|
335
322
|
nodes_path.write_text(json.dumps(nodes, indent=4))
|
|
336
323
|
|
|
324
|
+
env_path = project_path / ".env"
|
|
325
|
+
env_path.write_text(f"NODE={nodeID}\nHOST={host}\nPASSWORD={password}\nNETWORK={network}\nSYNAPSE={synapse}\n")
|
|
326
|
+
|
|
327
|
+
gitignore_path = project_path / ".gitignore"
|
|
328
|
+
gitignore_path.write_text(".env\n")
|
|
329
|
+
|
|
337
330
|
nodemd_path = project_path / "NODE.md"
|
|
338
|
-
nodemd_path.write_text(""
|
|
339
|
-
|
|
331
|
+
nodemd_path.write_text("## Use this NODE.md file to add instructions on how to interact with your node\n")
|
|
332
|
+
|
|
333
|
+
stx = sync or stream or host.replace("::cell", "::stx")
|
|
334
|
+
|
|
335
|
+
if sync:
|
|
336
|
+
sync_path = project_path / "sync.py"
|
|
337
|
+
sync_path.write_text(f"""\
|
|
338
|
+
import neuronum
|
|
339
|
+
import os
|
|
340
|
+
from dotenv import load_dotenv
|
|
341
|
+
|
|
342
|
+
load_dotenv()
|
|
343
|
+
host = os.getenv("HOST")
|
|
344
|
+
password = os.getenv("PASSWORD")
|
|
345
|
+
network = os.getenv("NETWORK")
|
|
346
|
+
synapse = os.getenv("SYNAPSE")
|
|
347
|
+
|
|
348
|
+
cell = neuronum.Cell(
|
|
349
|
+
host=host,
|
|
350
|
+
password=password,
|
|
351
|
+
network=network,
|
|
352
|
+
synapse=synapse
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
STX = "{stx}"
|
|
356
|
+
stream = cell.sync(STX)
|
|
357
|
+
for operation in stream:
|
|
358
|
+
label = operation.get("label")
|
|
359
|
+
value = operation.get("data").get("message")
|
|
360
|
+
ts = operation.get("time")
|
|
361
|
+
stxID = operation.get("stxID")
|
|
362
|
+
operator = operation.get("operator")
|
|
363
|
+
print(label, value, ts, stxID, operator)
|
|
340
364
|
""")
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
if stream:
|
|
368
|
+
stream_path = project_path / "stream.py"
|
|
369
|
+
stream_path.write_text(f"""\
|
|
344
370
|
import neuronum
|
|
345
371
|
import os
|
|
346
372
|
from dotenv import load_dotenv
|
|
@@ -358,7 +384,38 @@ cell = neuronum.Cell(
|
|
|
358
384
|
synapse=synapse
|
|
359
385
|
)
|
|
360
386
|
|
|
361
|
-
STX = "{
|
|
387
|
+
STX = "{stx}"
|
|
388
|
+
label = "your_label"
|
|
389
|
+
while True:
|
|
390
|
+
data = {{
|
|
391
|
+
"key1": "value1",
|
|
392
|
+
"key2": "value2",
|
|
393
|
+
"key3": "value3",
|
|
394
|
+
}}
|
|
395
|
+
cell.stream(label, data, STX)
|
|
396
|
+
""")
|
|
397
|
+
|
|
398
|
+
if not sync and not stream:
|
|
399
|
+
main_path = project_path / "main.py"
|
|
400
|
+
main_path.write_text(f"""\
|
|
401
|
+
import neuronum
|
|
402
|
+
import os
|
|
403
|
+
from dotenv import load_dotenv
|
|
404
|
+
|
|
405
|
+
load_dotenv()
|
|
406
|
+
host = os.getenv("HOST")
|
|
407
|
+
password = os.getenv("PASSWORD")
|
|
408
|
+
network = os.getenv("NETWORK")
|
|
409
|
+
synapse = os.getenv("SYNAPSE")
|
|
410
|
+
|
|
411
|
+
cell = neuronum.Cell(
|
|
412
|
+
host=host,
|
|
413
|
+
password=password,
|
|
414
|
+
network=network,
|
|
415
|
+
synapse=synapse
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
STX = "{stx}"
|
|
362
419
|
stream = cell.sync(STX)
|
|
363
420
|
for operation in stream:
|
|
364
421
|
label = operation.get("label")
|
|
@@ -366,29 +423,37 @@ for operation in stream:
|
|
|
366
423
|
ts = operation.get("time")
|
|
367
424
|
stxID = operation.get("stxID")
|
|
368
425
|
operator = operation.get("operator")
|
|
369
|
-
print(label, value, ts, stxID, operator)
|
|
426
|
+
print(label, value, ts, stxID, operator)
|
|
370
427
|
""")
|
|
371
428
|
|
|
372
429
|
click.echo(f"Neuronum Node '{nodeID}' initialized!")
|
|
373
430
|
|
|
374
431
|
|
|
432
|
+
|
|
375
433
|
@click.command()
|
|
376
434
|
def start_node():
|
|
377
435
|
click.echo("Starting Node...")
|
|
378
436
|
|
|
379
437
|
project_path = Path.cwd()
|
|
380
|
-
|
|
438
|
+
script_files = ["main.py", "sync.py", "stream.py"]
|
|
381
439
|
|
|
382
|
-
|
|
383
|
-
click.echo("Error: main.py not found. Make sure the node is set up.")
|
|
384
|
-
return
|
|
440
|
+
processes = []
|
|
385
441
|
|
|
386
|
-
|
|
442
|
+
for script in script_files:
|
|
443
|
+
script_path = project_path / script
|
|
444
|
+
if script_path.exists():
|
|
445
|
+
process = subprocess.Popen(["python", str(script_path)], start_new_session=True)
|
|
446
|
+
processes.append(process.pid)
|
|
447
|
+
|
|
448
|
+
if not processes:
|
|
449
|
+
click.echo("Error: No valid node script found. Ensure the node is set up correctly.")
|
|
450
|
+
return
|
|
387
451
|
|
|
388
452
|
with open("node_pid.txt", "w") as f:
|
|
389
|
-
f.write(str
|
|
453
|
+
f.write("\n".join(map(str, processes)))
|
|
454
|
+
|
|
455
|
+
click.echo(f"Node started successfully! Running {len(processes)} scripts: {', '.join(script_files)}")
|
|
390
456
|
|
|
391
|
-
click.echo("Node started successfully!")
|
|
392
457
|
|
|
393
458
|
|
|
394
459
|
@click.command()
|
|
@@ -397,12 +462,27 @@ def stop_node():
|
|
|
397
462
|
|
|
398
463
|
try:
|
|
399
464
|
with open("node_pid.txt", "r") as f:
|
|
400
|
-
|
|
401
|
-
|
|
465
|
+
pids = [int(pid.strip()) for pid in f.readlines()]
|
|
466
|
+
|
|
467
|
+
system_name = platform.system()
|
|
468
|
+
|
|
469
|
+
for pid in pids:
|
|
470
|
+
if system_name == "Windows":
|
|
471
|
+
subprocess.run(
|
|
472
|
+
["taskkill", "/F", "/PID", str(pid)],
|
|
473
|
+
stdout=subprocess.DEVNULL,
|
|
474
|
+
stderr=subprocess.DEVNULL
|
|
475
|
+
)
|
|
476
|
+
else:
|
|
477
|
+
os.kill(pid, 9)
|
|
478
|
+
|
|
402
479
|
os.remove("node_pid.txt")
|
|
403
480
|
click.echo("Node stopped successfully!")
|
|
481
|
+
|
|
404
482
|
except FileNotFoundError:
|
|
405
483
|
click.echo("Error: No active node process found.")
|
|
484
|
+
except subprocess.CalledProcessError:
|
|
485
|
+
click.echo("Error: Unable to stop some node processes.")
|
|
406
486
|
|
|
407
487
|
|
|
408
488
|
@click.command()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: neuronum
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.3
|
|
4
4
|
Summary: Official client library to interact with the Neuronum Network
|
|
5
5
|
Home-page: https://neuronum.net
|
|
6
6
|
Author: Neuronum Cybernetics
|
|
@@ -35,8 +35,8 @@ Dynamic: summary
|
|
|
35
35
|
|
|
36
36
|
Build, deploy and automate serverless data infrastructures for an interconnected world with `Neuronum`
|
|
37
37
|
|
|
38
|
-
### **What's New in neuronum==2.0.
|
|
39
|
-
- **
|
|
38
|
+
### **What's New in neuronum==2.0.3?**
|
|
39
|
+
- **Nodes/Node-CLI**: Initialize Nodes with autogenerated Stream and Sync templates
|
|
40
40
|
|
|
41
41
|
### New Feature Set
|
|
42
42
|
- **Cells/Cell-CLI**: Create and manage Neuronum Cells from the command line
|
|
@@ -91,7 +91,17 @@ Neuronum Nodes are soft- and hardware components that power the Neuronum Network
|
|
|
91
91
|
|
|
92
92
|
Initialize a Node:
|
|
93
93
|
```sh
|
|
94
|
-
$ neuronum init-node
|
|
94
|
+
$ neuronum init-node
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Initialize a Node with stream template:
|
|
98
|
+
```sh
|
|
99
|
+
$ neuronum init-node --stream id::stx
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Initialize a Node with sync template:
|
|
103
|
+
```sh
|
|
104
|
+
$ neuronum init-node --sync id::stx
|
|
95
105
|
```
|
|
96
106
|
|
|
97
107
|
Start a Node:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
cellai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
cellai/cellai.py,sha256=g5oBz-Xx6T4-JWzUs-TJ4y9nHtDmA_IpXh_188OqAZA,281
|
|
3
3
|
cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
cli/main.py,sha256=
|
|
4
|
+
cli/main.py,sha256=ppfbah4h-b0m33FgZSmVfIA8rHCk6m_wZO-P1o4BpSg,20557
|
|
5
5
|
neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
|
|
6
6
|
neuronum/neuronum.py,sha256=rkc16omTxjWBEgBXP0rCeab1S3lYDKz1zx_i-tdFjlY,17544
|
|
7
|
-
neuronum-2.0.
|
|
8
|
-
neuronum-2.0.
|
|
9
|
-
neuronum-2.0.
|
|
10
|
-
neuronum-2.0.
|
|
11
|
-
neuronum-2.0.
|
|
12
|
-
neuronum-2.0.
|
|
7
|
+
neuronum-2.0.3.dist-info/licenses/LICENSE,sha256=UiZjNHiCyRP6WoZfbYQh9cv4JW96wIofKXmzBJrYSUk,1125
|
|
8
|
+
neuronum-2.0.3.dist-info/METADATA,sha256=g96Vd_rIom8dRvCT0Pb4PJTyNnSyEtNp2X7B1DPXSoM,13942
|
|
9
|
+
neuronum-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
neuronum-2.0.3.dist-info/entry_points.txt,sha256=XKYBcRNxGeJpZZkDPsa8HA_RaJ7Km_R_JaUq5T9Nk2U,42
|
|
11
|
+
neuronum-2.0.3.dist-info/top_level.txt,sha256=gqN5tyGnBKMPSzvWQONO4rpTf4gQPMi77O3KAKx88LQ,20
|
|
12
|
+
neuronum-2.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|