neuronum 0.6.0__tar.gz → 0.7.0__tar.gz
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-0.6.0 → neuronum-0.7.0}/PKG-INFO +7 -2
- neuronum-0.7.0/neuronum/neuronum.py +145 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum.egg-info/PKG-INFO +7 -2
- {neuronum-0.6.0 → neuronum-0.7.0}/setup.py +1 -1
- neuronum-0.6.0/neuronum/neuronum.py +0 -86
- {neuronum-0.6.0 → neuronum-0.7.0}/README.md +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum/__init__.py +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum.egg-info/SOURCES.txt +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum.egg-info/dependency_links.txt +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum.egg-info/requires.txt +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/neuronum.egg-info/top_level.txt +0 -0
- {neuronum-0.6.0 → neuronum-0.7.0}/setup.cfg +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: neuronum
|
|
3
|
-
Version: 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
|
+
Dynamic: author
|
|
10
|
+
Dynamic: author-email
|
|
11
|
+
Dynamic: requires-dist
|
|
12
|
+
Dynamic: requires-python
|
|
13
|
+
Dynamic: summary
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Cell:
|
|
6
|
+
def __init__(self, host: str, password: str, network: str, synapse: str):
|
|
7
|
+
self.host = host
|
|
8
|
+
self.password = password
|
|
9
|
+
self.network = network
|
|
10
|
+
self.synapse = synapse
|
|
11
|
+
|
|
12
|
+
def to_dict(self) -> dict:
|
|
13
|
+
return {
|
|
14
|
+
"host": self.host,
|
|
15
|
+
"password": self.password,
|
|
16
|
+
"synapse": self.synapse
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def __repr__(self) -> str:
|
|
20
|
+
return f"Cell(host={self.host}, password={self.password}, network={self.network}, synapse={self.synapse})"
|
|
21
|
+
|
|
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}"
|
|
24
|
+
|
|
25
|
+
TX = {
|
|
26
|
+
"data": data,
|
|
27
|
+
"cell": self.to_dict()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
response = requests.post(
|
|
32
|
+
full_url,
|
|
33
|
+
json=TX,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
response.raise_for_status()
|
|
37
|
+
|
|
38
|
+
print(f"Response from FastAPI backend: {response.json()}")
|
|
39
|
+
|
|
40
|
+
except requests.exceptions.RequestException as e:
|
|
41
|
+
print(f"Error sending request: {e}")
|
|
42
|
+
except Exception as e:
|
|
43
|
+
print(f"Unexpected error: {e}")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_connection(self, base_url: str = "http://{network}:8000/testConnection"):
|
|
48
|
+
full_url = base_url.format(network=self.network)
|
|
49
|
+
|
|
50
|
+
TX = {
|
|
51
|
+
"host": self.host,
|
|
52
|
+
"password": self.password,
|
|
53
|
+
"synapse": self.synapse
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
print(TX)
|
|
57
|
+
|
|
58
|
+
try:
|
|
59
|
+
response = requests.post(
|
|
60
|
+
full_url,
|
|
61
|
+
json=TX,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
response.raise_for_status()
|
|
65
|
+
print(f"Response from FastAPI backend: {response.json()}")
|
|
66
|
+
|
|
67
|
+
except requests.exceptions.RequestException as e:
|
|
68
|
+
print(f"Error sending request: {e}")
|
|
69
|
+
except Exception as e:
|
|
70
|
+
print(f"Unexpected error: {e}")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
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
|
+
|
|
145
|
+
__all__ = ['Cell']
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: neuronum
|
|
3
|
-
Version: 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
|
+
Dynamic: author
|
|
10
|
+
Dynamic: author-email
|
|
11
|
+
Dynamic: requires-dist
|
|
12
|
+
Dynamic: requires-python
|
|
13
|
+
Dynamic: summary
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
from typing import Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Cell:
|
|
6
|
-
def __init__(self, host: str, password: str, circuit: str, synapse: str):
|
|
7
|
-
self.host = host
|
|
8
|
-
self.password = password
|
|
9
|
-
self.circuit = circuit
|
|
10
|
-
self.synapse = synapse
|
|
11
|
-
|
|
12
|
-
def to_dict(self) -> dict:
|
|
13
|
-
return {
|
|
14
|
-
"host": self.host,
|
|
15
|
-
"password": self.password,
|
|
16
|
-
"synapse": self.synapse
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
def __repr__(self) -> str:
|
|
20
|
-
return f"Cell(host={self.host}, password={self.password}, circuit={self.circuit}, synapse={self.synapse})"
|
|
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}"
|
|
25
|
-
|
|
26
|
-
nt = {
|
|
27
|
-
"data": data,
|
|
28
|
-
"cell": self.to_dict() # Serialize the Cell instance to a dictionary
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try:
|
|
32
|
-
# Send the POST request without mutual TLS (no cert)
|
|
33
|
-
response = requests.post(
|
|
34
|
-
full_url,
|
|
35
|
-
json=nt,
|
|
36
|
-
verify=True # Optionally verify the server's SSL certificate (set path to CA bundle if needed)
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
# Raise an error for bad status codes
|
|
40
|
-
response.raise_for_status()
|
|
41
|
-
|
|
42
|
-
# Print the successful response from the backend (FastAPI server)
|
|
43
|
-
print(f"Response from FastAPI backend: {response.json()}")
|
|
44
|
-
|
|
45
|
-
except requests.exceptions.RequestException as e:
|
|
46
|
-
print(f"Error sending request: {e}")
|
|
47
|
-
except Exception as e:
|
|
48
|
-
print(f"Unexpected error: {e}")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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)
|
|
55
|
-
|
|
56
|
-
nt = {
|
|
57
|
-
"host": self.host,
|
|
58
|
-
"password": self.password,
|
|
59
|
-
"synapse": self.synapse # Serialize the Cell instance to a dictionary
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
print(nt)
|
|
63
|
-
|
|
64
|
-
try:
|
|
65
|
-
# Send the POST request without mutual TLS (no cert)
|
|
66
|
-
response = requests.post(
|
|
67
|
-
full_url,
|
|
68
|
-
json=nt,
|
|
69
|
-
verify=True # Optionally verify the server's SSL certificate (set path to CA bundle if needed)
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
# Raise an error for bad status codes
|
|
73
|
-
response.raise_for_status()
|
|
74
|
-
|
|
75
|
-
# Print the successful response from the backend (FastAPI server)
|
|
76
|
-
print(f"Response from FastAPI backend: {response.json()}")
|
|
77
|
-
|
|
78
|
-
except requests.exceptions.RequestException as e:
|
|
79
|
-
print(f"Error sending request: {e}")
|
|
80
|
-
except Exception as e:
|
|
81
|
-
print(f"Unexpected error: {e}")
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# Now, explicitly expose these components for easy import
|
|
86
|
-
__all__ = ['Cell']
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|