neuronum 0.6.0__py3-none-any.whl → 0.7.0__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
@@ -3,10 +3,10 @@ from typing import Optional
3
3
 
4
4
 
5
5
  class Cell:
6
- def __init__(self, host: str, password: str, circuit: str, synapse: str):
6
+ def __init__(self, host: str, password: str, network: str, synapse: str):
7
7
  self.host = host
8
8
  self.password = password
9
- self.circuit = circuit
9
+ self.network = network
10
10
  self.synapse = synapse
11
11
 
12
12
  def to_dict(self) -> dict:
@@ -17,29 +17,24 @@ class Cell:
17
17
  }
18
18
 
19
19
  def __repr__(self) -> str:
20
- return f"Cell(host={self.host}, password={self.password}, circuit={self.circuit}, synapse={self.synapse})"
20
+ return f"Cell(host={self.host}, password={self.password}, network={self.network}, synapse={self.synapse})"
21
21
 
22
- def execute(self, taskID: str, data: dict, base_url: str = "https://{circuit}:443/executeTask"):
23
- # Format the URL with circuit and include taskID as a query parameter
24
- full_url = base_url.format(circuit=self.circuit) + f"/{taskID}"
22
+ def activate(self, txID: str, data: dict, base_url: str = "http://{network}:8000/activateTX"):
23
+ full_url = base_url.format(network=self.network) + f"/{txID}"
25
24
 
26
- nt = {
25
+ TX = {
27
26
  "data": data,
28
- "cell": self.to_dict() # Serialize the Cell instance to a dictionary
27
+ "cell": self.to_dict()
29
28
  }
30
29
 
31
30
  try:
32
- # Send the POST request without mutual TLS (no cert)
33
31
  response = requests.post(
34
32
  full_url,
35
- json=nt,
36
- verify=True # Optionally verify the server's SSL certificate (set path to CA bundle if needed)
33
+ json=TX,
37
34
  )
38
35
 
39
- # Raise an error for bad status codes
40
36
  response.raise_for_status()
41
37
 
42
- # Print the successful response from the backend (FastAPI server)
43
38
  print(f"Response from FastAPI backend: {response.json()}")
44
39
 
45
40
  except requests.exceptions.RequestException as e:
@@ -49,30 +44,24 @@ class Cell:
49
44
 
50
45
 
51
46
 
52
- def test_connection(self, base_url: str = "https://{circuit}:443/testConnection"):
53
- # Format the URL with circuit and include taskID as a query parameter
54
- full_url = base_url.format(circuit=self.circuit)
47
+ def test_connection(self, base_url: str = "http://{network}:8000/testConnection"):
48
+ full_url = base_url.format(network=self.network)
55
49
 
56
- nt = {
50
+ TX = {
57
51
  "host": self.host,
58
52
  "password": self.password,
59
- "synapse": self.synapse # Serialize the Cell instance to a dictionary
53
+ "synapse": self.synapse
60
54
  }
61
55
 
62
- print(nt)
56
+ print(TX)
63
57
 
64
58
  try:
65
- # Send the POST request without mutual TLS (no cert)
66
59
  response = requests.post(
67
60
  full_url,
68
- json=nt,
69
- verify=True # Optionally verify the server's SSL certificate (set path to CA bundle if needed)
61
+ json=TX,
70
62
  )
71
63
 
72
- # Raise an error for bad status codes
73
64
  response.raise_for_status()
74
-
75
- # Print the successful response from the backend (FastAPI server)
76
65
  print(f"Response from FastAPI backend: {response.json()}")
77
66
 
78
67
  except requests.exceptions.RequestException as e:
@@ -82,5 +71,75 @@ class Cell:
82
71
 
83
72
 
84
73
 
85
- # Now, explicitly expose these components for easy import
74
+
75
+ def store(self, label: str, data: dict, ctx: Optional[str] = None):
76
+ if ctx:
77
+ full_url = f"http://{self.network}:8000/store_ctx/{ctx}"
78
+ else:
79
+ full_url = f"http://{self.network}:8000/store"
80
+
81
+ store = {
82
+ "label": label,
83
+ "data": data,
84
+ "cell": self.to_dict()
85
+ }
86
+
87
+ try:
88
+ response = requests.post(full_url, json=store)
89
+ response.raise_for_status()
90
+ print(f"Response from FastAPI backend: {response.json()}")
91
+ except requests.exceptions.RequestException as e:
92
+ print(f"Error sending request: {e}")
93
+ except Exception as e:
94
+ print(f"Unexpected error: {e}")
95
+
96
+
97
+
98
+ def load(self, label: str, ctx: Optional[str] = None):
99
+ if ctx:
100
+ full_url = f"http://{self.network}:8000/load_ctx/{ctx}"
101
+ else:
102
+ full_url = f"http://{self.network}:8000/load"
103
+
104
+ print(f"Full URL: {full_url}")
105
+
106
+ load = {
107
+ "label": label,
108
+ "cell": self.to_dict()
109
+ }
110
+
111
+ try:
112
+ response = requests.post(full_url, json=load)
113
+ response.raise_for_status()
114
+ return response.json()
115
+ except requests.exceptions.RequestException as e:
116
+ print(f"Error sending request: {e}")
117
+ except Exception as e:
118
+ print(f"Unexpected error: {e}")
119
+
120
+
121
+
122
+ def delete(self, label: str, ctx: Optional[str] = None):
123
+ if ctx:
124
+ full_url = f"http://{self.network}:8000/delete_ctx/{ctx}"
125
+ else:
126
+ full_url = f"http://{self.network}:8000/delete"
127
+
128
+ print(f"Full URL: {full_url}")
129
+
130
+ delete = {
131
+ "label": label,
132
+ "cell": self.to_dict()
133
+ }
134
+
135
+ try:
136
+ response = requests.post(full_url, json=delete)
137
+ response.raise_for_status()
138
+ print(response.json())
139
+ except requests.exceptions.RequestException as e:
140
+ print(f"Error sending request: {e}")
141
+ except Exception as e:
142
+ print(f"Unexpected error: {e}")
143
+
144
+
86
145
  __all__ = ['Cell']
@@ -1,9 +1,13 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: neuronum
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: A high-level coding library to interact with the Neuronum network.
5
5
  Author: Neuronum Cybernetics
6
6
  Author-email: welcome@neuronum.net
7
7
  Requires-Python: >=3.6
8
8
  Requires-Dist: requests
9
-
9
+ Dynamic: author
10
+ Dynamic: author-email
11
+ Dynamic: requires-dist
12
+ Dynamic: requires-python
13
+ Dynamic: summary
@@ -0,0 +1,6 @@
1
+ neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
2
+ neuronum/neuronum.py,sha256=0ca2qdduBk-X6tIwln4-LMz-BLbhQHbZM6zUd9gM5cs,4299
3
+ neuronum-0.7.0.dist-info/METADATA,sha256=lorcVD9ZFpDlfmxyFg-2M0LVtF3rERv9lmHebyo3WzQ,355
4
+ neuronum-0.7.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ neuronum-0.7.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
6
+ neuronum-0.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
2
- neuronum/neuronum.py,sha256=pEOlS-er-80Oa_11LFDX8HuR1mIztq3Y-9I7y7LV4qs,3070
3
- neuronum-0.6.0.dist-info/METADATA,sha256=Mo7mB_p5AnM4UWXv_ENxyJ91r7evm3deLTnmwjiHz6Q,249
4
- neuronum-0.6.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
5
- neuronum-0.6.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
6
- neuronum-0.6.0.dist-info/RECORD,,