neuronum 0.2.0__tar.gz → 0.4.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neuronum
3
- Version: 0.2.0
3
+ Version: 0.4.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
@@ -0,0 +1,5 @@
1
+ # neuronum/__init__.py
2
+
3
+ from .neuronum import Cell
4
+
5
+ __all__ = ['Cell']
@@ -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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: neuronum
3
- Version: 0.2.0
3
+ Version: 0.4.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
@@ -1,5 +1,7 @@
1
1
  README.md
2
2
  setup.py
3
+ neuronum/__init__.py
4
+ neuronum/neuronum.py
3
5
  neuronum.egg-info/PKG-INFO
4
6
  neuronum.egg-info/SOURCES.txt
5
7
  neuronum.egg-info/dependency_links.txt
@@ -0,0 +1 @@
1
+ neuronum
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='neuronum',
5
- version='0.2.0',
5
+ version='0.4.0',
6
6
  author='Neuronum Cybernetics',
7
7
  author_email='welcome@neuronum.net',
8
8
  description='A high-level coding library to interact with the Neuronum network.',
File without changes
File without changes