neuronum 0.6.0__py3-none-any.whl → 0.8.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 +85 -26
- {neuronum-0.6.0.dist-info → neuronum-0.8.0.dist-info}/METADATA +2 -2
- neuronum-0.8.0.dist-info/RECORD +6 -0
- neuronum-0.6.0.dist-info/RECORD +0 -6
- {neuronum-0.6.0.dist-info → neuronum-0.8.0.dist-info}/WHEEL +0 -0
- {neuronum-0.6.0.dist-info → neuronum-0.8.0.dist-info}/top_level.txt +0 -0
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,
|
|
6
|
+
def __init__(self, host: str, password: str, network: str, synapse: str):
|
|
7
7
|
self.host = host
|
|
8
8
|
self.password = password
|
|
9
|
-
self.
|
|
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},
|
|
20
|
+
return f"Cell(host={self.host}, password={self.password}, network={self.network}, synapse={self.synapse})"
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
|
|
24
|
-
full_url = base_url.format(circuit=self.circuit) + f"/{taskID}"
|
|
22
|
+
def activate(self, txID: str, data: dict, base_url: str = "http://{network}/activateTX"):
|
|
23
|
+
full_url = base_url.format(network=self.network) + f"/{txID}"
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
TX = {
|
|
27
26
|
"data": data,
|
|
28
|
-
"cell": self.to_dict()
|
|
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=
|
|
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 = "
|
|
53
|
-
|
|
54
|
-
full_url = base_url.format(circuit=self.circuit)
|
|
47
|
+
def test_connection(self, base_url: str = "http://{network}/testConnection"):
|
|
48
|
+
full_url = base_url.format(network=self.network)
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
TX = {
|
|
57
51
|
"host": self.host,
|
|
58
52
|
"password": self.password,
|
|
59
|
-
"synapse": self.synapse
|
|
53
|
+
"synapse": self.synapse
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
print(
|
|
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=
|
|
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
|
-
|
|
74
|
+
|
|
75
|
+
def store(self, label: str, data: dict, ctx: Optional[str] = None):
|
|
76
|
+
if ctx:
|
|
77
|
+
full_url = f"http://{self.network}/store_ctx/{ctx}"
|
|
78
|
+
else:
|
|
79
|
+
full_url = f"http://{self.network}/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}/load_ctx/{ctx}"
|
|
101
|
+
else:
|
|
102
|
+
full_url = f"http://{self.network}/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}/delete_ctx/{ctx}"
|
|
125
|
+
else:
|
|
126
|
+
full_url = f"http://{self.network}/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,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: neuronum
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: A high-level coding library to
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: A high-level coding library to build & automate economic data streams - The Neuronum Team
|
|
5
5
|
Author: Neuronum Cybernetics
|
|
6
6
|
Author-email: welcome@neuronum.net
|
|
7
7
|
Requires-Python: >=3.6
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
|
|
2
|
+
neuronum/neuronum.py,sha256=Qpcal4FhbUFpZoVaEJxVD_qM9X-Eq4Lw-vYqr_JbEGU,4259
|
|
3
|
+
neuronum-0.8.0.dist-info/METADATA,sha256=_xpsILXcEZPifvSdtpUoRTFHgXbMwQKcrTrC5k2qnLc,272
|
|
4
|
+
neuronum-0.8.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
5
|
+
neuronum-0.8.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
6
|
+
neuronum-0.8.0.dist-info/RECORD,,
|
neuronum-0.6.0.dist-info/RECORD
DELETED
|
@@ -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,,
|
|
File without changes
|
|
File without changes
|