neuronum 5.8.4__py3-none-any.whl → 5.8.5__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 CHANGED
@@ -82,17 +82,18 @@ class Cell:
82
82
 
83
83
  async def sync(self, stx: Optional[str] = None) -> AsyncGenerator[str, None]:
84
84
  full_url = f"wss://{self.network}/sync/{stx}"
85
-
86
85
  auth_payload = {
87
86
  "host": self.host,
88
87
  "password": self.password,
89
88
  "synapse": self.synapse,
90
89
  }
91
90
 
92
- try:
93
- async with websockets.connect(full_url) as ws:
94
- await ws.send(json.dumps(auth_payload))
95
- try:
91
+ while True:
92
+ try:
93
+ async with websockets.connect(full_url) as ws:
94
+ await ws.send(json.dumps(auth_payload))
95
+ print("Connected to WebSocket.")
96
+
96
97
  while True:
97
98
  try:
98
99
  raw_operation = await ws.recv()
@@ -100,17 +101,20 @@ class Cell:
100
101
  yield operation
101
102
 
102
103
  except asyncio.TimeoutError:
103
- print("No initial data received. Continuing to listen...")
104
- continue
105
-
106
- except asyncio.CancelledError:
107
- print("Connection closed.")
108
-
109
- except websockets.exceptions.WebSocketException as e:
110
- print(f"WebSocket error occurred: {e}")
104
+ print("No data received. Continuing...")
105
+ except websockets.exceptions.ConnectionClosedError as e:
106
+ print(f"Connection closed with error: {e}. Reconnecting...")
107
+ break
108
+ except Exception as e:
109
+ print(f"Unexpected error in recv loop: {e}")
110
+ break
111
+
112
+ except websockets.exceptions.WebSocketException as e:
113
+ print(f"WebSocket error occurred: {e}. Retrying in 5 seconds...")
114
+ except Exception as e:
115
+ print(f"General error occurred: {e}. Retrying in 5 seconds...")
111
116
 
112
- except Exception as e:
113
- print(f"An unexpected error occurred: {e}")
117
+ await asyncio.sleep(3)
114
118
 
115
119
 
116
120
  async def create_tx(self, descr: str, key_values: dict, stx: str, label: str, partners: list):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuronum
3
- Version: 5.8.4
3
+ Version: 5.8.5
4
4
  Summary: Official client library to interact with the Neuronum Network
5
5
  Home-page: https://neuronum.net
6
6
  Author: Neuronum Cybernetics
@@ -64,7 +64,7 @@ In this brief getting started guide, you will:
64
64
  ------------------
65
65
 
66
66
  ### **About Neuronum**
67
- Neuronum empowers developers to build & connect apps, services, and devices into serverless networks able to exchange data in real time
67
+ Neuronum empowers developers to build, ship & connect apps, services, and devices into serverless networks able to exchange data in real time
68
68
 
69
69
  ### **Features**
70
70
  **Cell & Nodes**
@@ -104,7 +104,7 @@ neuronum connect-cell # connect Cell
104
104
 
105
105
 
106
106
  ### **Build On Neuronum**
107
- [View Node Examples](https://github.com/neuronumcybernetics/neuronum/tree/main/features/nodes)
107
+ To dive deeper into Neuronum App development, visit & build with [Node Examples](https://github.com/neuronumcybernetics/neuronum/tree/main/features/nodes/examples)
108
108
 
109
109
 
110
110
  Initialize a Node (app template):
@@ -112,6 +112,94 @@ Initialize a Node (app template):
112
112
  neuronum init-node --app # initialize a Node with app template
113
113
  ```
114
114
 
115
+ This command prompts you to enter a Node description (e.g Getting Started Node) and creates a new directory named node_<node_id> containing the following files:
116
+
117
+ .env
118
+ ```env
119
+ NODE=your_node_id
120
+ HOST=your_cell_id
121
+ PASSWORD=your_password
122
+ NETWORK=neuronum.net
123
+ SYNAPSE=your_synapse # auth token
124
+ ```
125
+
126
+ app.py
127
+ ```python
128
+ import asyncio
129
+ import neuronum
130
+ import os
131
+ from dotenv import load_dotenv
132
+
133
+ load_dotenv()
134
+ host = os.getenv("HOST")
135
+ password = os.getenv("PASSWORD")
136
+ network = os.getenv("NETWORK")
137
+ synapse = os.getenv("SYNAPSE")
138
+
139
+ cell = neuronum.Cell(
140
+ host=host,
141
+ password=password,
142
+ network=network,
143
+ synapse=synapse
144
+ )
145
+
146
+ async def main():
147
+ STX = "id::stx"
148
+ async for operation in cell.sync(STX):
149
+ txID = operation.get("txID")
150
+ client = operation.get("operator")
151
+
152
+ if txID == "id::tx":
153
+ data = {
154
+ "json": f"Hello {client}",
155
+ "html": f"""
156
+ <!DOCTYPE html>
157
+ <html>
158
+ <head>
159
+ <meta charset="UTF-8">
160
+ <title>Greeting Node</title>
161
+ </head>
162
+ <body>
163
+ <div class="card">
164
+ <h1>Hello, {client}</h1>
165
+ </div>
166
+ </body>
167
+ </html>
168
+ """
169
+
170
+ }
171
+ await cell.tx_response(txID, client, data)
172
+
173
+ asyncio.run(main())
174
+ ```
175
+
176
+ NODE.md
177
+ ```
178
+ ```json
179
+ {
180
+ "gateways": [
181
+ {
182
+ "type": "stream",
183
+ "id": "id::stx",
184
+ "link": "https://neuronum.net/stream/id::stx",
185
+ "info": "stream info"
186
+ },
187
+ {
188
+ "type": "transmitter",
189
+ "id": "id::tx",
190
+ "link": "https://neuronum.net/tx/id::tx",
191
+ "info": "transmitter info"
192
+ },
193
+ {
194
+ "type": "circuit",
195
+ "id": "id::ctx",
196
+ "link": "https://neuronum.net/circuit/id::ctx",
197
+ "info": "circuit info"
198
+ }
199
+ ]
200
+ }
201
+ ```
202
+
115
203
  Change into Node folder
116
204
  ```sh
117
205
  cd node_node_id # change directory
@@ -0,0 +1,10 @@
1
+ cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cli/main.py,sha256=Yec9ovjqM6iI6IyUU8nhgrpcd7rIMocSoZI8QWY1KC4,35684
3
+ neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
4
+ neuronum/neuronum.py,sha256=ShcnqXZshUlRuqMQC-8S7_A0xutsW8R5UUr8zvvjm0g,17565
5
+ neuronum-5.8.5.dist-info/licenses/LICENSE.md,sha256=zGst0rjgnp6oFuRVwFwB1Ql4sDXt_nw9xbUR49Gf99A,2008
6
+ neuronum-5.8.5.dist-info/METADATA,sha256=WJLvc2xnldC7tN-iC9jyAFx5AngFFhCYxC8xJKLlG8Q,7443
7
+ neuronum-5.8.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ neuronum-5.8.5.dist-info/entry_points.txt,sha256=XKYBcRNxGeJpZZkDPsa8HA_RaJ7Km_R_JaUq5T9Nk2U,42
9
+ neuronum-5.8.5.dist-info/top_level.txt,sha256=ru8Fr84cHm6oHr_DcJ8-uaq3RTiuCRFIr6AC8V0zPu4,13
10
+ neuronum-5.8.5.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cli/main.py,sha256=Yec9ovjqM6iI6IyUU8nhgrpcd7rIMocSoZI8QWY1KC4,35684
3
- neuronum/__init__.py,sha256=Drsm263_w3_VWgl1YsKLUr8WwVodqV3TSjqpxLjyq_M,46
4
- neuronum/neuronum.py,sha256=L8Oz1qcTyOiYMTGfiSKgN5Nu9jcl25jFeJOh0XItPjw,17201
5
- neuronum-5.8.4.dist-info/licenses/LICENSE.md,sha256=zGst0rjgnp6oFuRVwFwB1Ql4sDXt_nw9xbUR49Gf99A,2008
6
- neuronum-5.8.4.dist-info/METADATA,sha256=T9p6cUzgU3c2P9uvagnunGkRVrvC7DKAZZV26JdSQlQ,5367
7
- neuronum-5.8.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- neuronum-5.8.4.dist-info/entry_points.txt,sha256=XKYBcRNxGeJpZZkDPsa8HA_RaJ7Km_R_JaUq5T9Nk2U,42
9
- neuronum-5.8.4.dist-info/top_level.txt,sha256=ru8Fr84cHm6oHr_DcJ8-uaq3RTiuCRFIr6AC8V0zPu4,13
10
- neuronum-5.8.4.dist-info/RECORD,,