neuronum 0.3.0__py3-none-any.whl → 0.5.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/__init__.py +5 -0
- neuronum/neuronum.py +86 -0
- {neuronum-0.3.0.dist-info → neuronum-0.5.0.dist-info}/METADATA +2 -1
- neuronum-0.5.0.dist-info/RECORD +6 -0
- neuronum-0.5.0.dist-info/top_level.txt +1 -0
- neuronum-0.3.0.dist-info/RECORD +0 -4
- neuronum-0.3.0.dist-info/top_level.txt +0 -1
- {neuronum-0.3.0.dist-info → neuronum-0.5.0.dist-info}/WHEEL +0 -0
neuronum/__init__.py
ADDED
neuronum/neuronum.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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=False # 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=False # 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']
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: neuronum
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
+
Requires-Dist: requests
|
|
8
9
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
neuronum/__init__.py,sha256=P0KTJMGY_eT3l5YzR4LHfl64KH5Qt_qhcrqf9Ld2G00,74
|
|
2
|
+
neuronum/neuronum.py,sha256=uBbfk14o6eyAAAa5pTil3g1ygCpN3AaRyXD323MAoOY,3072
|
|
3
|
+
neuronum-0.5.0.dist-info/METADATA,sha256=w9jO6StWbP9oXZvl9dyeltJEK49JXSEwxfGxsmp7rC0,249
|
|
4
|
+
neuronum-0.5.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
5
|
+
neuronum-0.5.0.dist-info/top_level.txt,sha256=73zXVVO9UTTiwEcSaXytsJ8n0q47OCwAqPlIh-hzWJU,9
|
|
6
|
+
neuronum-0.5.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
neuronum
|
neuronum-0.3.0.dist-info/RECORD
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
neuronum-0.3.0.dist-info/METADATA,sha256=v_t8zE8ATX37nKQ5-F3MgIHE11g8R_fECHJjiKDp_c4,224
|
|
2
|
-
neuronum-0.3.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
3
|
-
neuronum-0.3.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
4
|
-
neuronum-0.3.0.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|