naeural-client 2.7.7__py3-none-any.whl → 2.7.8__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.
- naeural_client/_ver.py +1 -1
- naeural_client/base/generic_session.py +69 -17
- naeural_client/base/pipeline.py +15 -2
- naeural_client/const/payload.py +1 -0
- {naeural_client-2.7.7.dist-info → naeural_client-2.7.8.dist-info}/METADATA +1 -1
- {naeural_client-2.7.7.dist-info → naeural_client-2.7.8.dist-info}/RECORD +9 -9
- {naeural_client-2.7.7.dist-info → naeural_client-2.7.8.dist-info}/WHEEL +0 -0
- {naeural_client-2.7.7.dist-info → naeural_client-2.7.8.dist-info}/entry_points.txt +0 -0
- {naeural_client-2.7.7.dist-info → naeural_client-2.7.8.dist-info}/licenses/LICENSE +0 -0
naeural_client/_ver.py
CHANGED
@@ -212,7 +212,8 @@ class GenericSession(BaseDecentrAIObject):
|
|
212
212
|
self._dct_online_nodes_last_heartbeat: dict[str, dict] = {}
|
213
213
|
self._dct_can_send_to_node: dict[str, bool] = {}
|
214
214
|
self._dct_node_last_seen_time = {} # key is node address
|
215
|
-
self.
|
215
|
+
self.__dct_node_address_to_alias = {}
|
216
|
+
self.__dct_node_eth_addr_to_node_addr = {}
|
216
217
|
|
217
218
|
self._dct_netconfig_pipelines_requests = {}
|
218
219
|
|
@@ -486,17 +487,24 @@ class GenericSession(BaseDecentrAIObject):
|
|
486
487
|
"""
|
487
488
|
return self.filter_workers is not None and node_addr not in self.filter_workers
|
488
489
|
|
489
|
-
def __track_online_node(self, node_addr, node_id):
|
490
|
+
def __track_online_node(self, node_addr, node_id, node_eth_address=None):
|
490
491
|
"""
|
491
492
|
Track the last time a node was seen online.
|
492
493
|
|
493
494
|
Parameters
|
494
495
|
----------
|
496
|
+
node_id : str
|
497
|
+
The alias of the Ratio1 edge node that sent the message.
|
495
498
|
node_addr : str
|
496
|
-
The address of the
|
499
|
+
The address of the Ratio1 edge node that sent the message.
|
500
|
+
node_eth_address : str, optional
|
501
|
+
The Ethereum address of the Ratio1 edge node that sent the message, by
|
497
502
|
"""
|
498
503
|
self._dct_node_last_seen_time[node_addr] = tm()
|
499
|
-
self.
|
504
|
+
self.__dct_node_address_to_alias[node_addr] = node_id
|
505
|
+
if node_eth_address is not None:
|
506
|
+
self.__dct_node_eth_addr_to_node_addr[node_eth_address] = node_addr
|
507
|
+
# endif node_eth address not provided - this is just for safety and it should not happen!
|
500
508
|
return
|
501
509
|
|
502
510
|
def __track_allowed_node_by_hb(self, node_addr, dict_msg):
|
@@ -586,9 +594,14 @@ class GenericSession(BaseDecentrAIObject):
|
|
586
594
|
node_secured = dict_msg.get(PAYLOAD_DATA.NETMON_NODE_SECURED, False)
|
587
595
|
node_online = dict_msg.get(PAYLOAD_DATA.NETMON_STATUS_KEY) == PAYLOAD_DATA.NETMON_STATUS_ONLINE
|
588
596
|
node_alias = dict_msg.get(PAYLOAD_DATA.NETMON_EEID, None)
|
597
|
+
node_eth_address = dict_msg.get(PAYLOAD_DATA.NETMON_ETH_ADDRESS, None)
|
589
598
|
|
590
599
|
if node_online:
|
591
|
-
self.__track_online_node(
|
600
|
+
self.__track_online_node(
|
601
|
+
node_addr=node_addr,
|
602
|
+
node_id=node_alias,
|
603
|
+
node_eth_address=node_eth_address
|
604
|
+
)
|
592
605
|
|
593
606
|
client_is_allowed = self.bc_engine.contains_current_address(node_whitelist)
|
594
607
|
can_send = not node_secured or client_is_allowed or self.bc_engine.address == node_addr
|
@@ -654,9 +667,14 @@ class GenericSession(BaseDecentrAIObject):
|
|
654
667
|
self._dct_online_nodes_last_heartbeat[msg_node_addr] = dict_msg
|
655
668
|
|
656
669
|
msg_node_id = dict_msg[PAYLOAD_DATA.EE_ID]
|
670
|
+
msg_node_eth_addr = dict_msg.get(PAYLOAD_DATA.EE_ETH_ADDR, None)
|
657
671
|
# track the node based on heartbeat - a normal heartbeat means the node is online
|
658
672
|
# however this can lead to long wait times for the first heartbeat for all nodes
|
659
|
-
self.__track_online_node(
|
673
|
+
self.__track_online_node(
|
674
|
+
node_addr=msg_node_addr,
|
675
|
+
node_id=msg_node_id,
|
676
|
+
node_eth_address=msg_node_eth_addr
|
677
|
+
)
|
660
678
|
|
661
679
|
msg_active_configs = dict_msg.get(HB.CONFIG_STREAMS)
|
662
680
|
if msg_active_configs is None:
|
@@ -1379,12 +1397,12 @@ class GenericSession(BaseDecentrAIObject):
|
|
1379
1397
|
self._config[comm_ct.SECURED] = secured
|
1380
1398
|
|
1381
1399
|
return
|
1382
|
-
|
1400
|
+
|
1383
1401
|
def __aliases_to_addresses(self):
|
1384
1402
|
"""
|
1385
1403
|
Convert the aliases to addresses.
|
1386
1404
|
"""
|
1387
|
-
dct_aliases = {v: k for k, v in self.
|
1405
|
+
dct_aliases = {v: k for k, v in self.__dct_node_address_to_alias.items()}
|
1388
1406
|
return dct_aliases
|
1389
1407
|
|
1390
1408
|
def __get_node_address(self, node):
|
@@ -1403,12 +1421,13 @@ class GenericSession(BaseDecentrAIObject):
|
|
1403
1421
|
str
|
1404
1422
|
The address of the node.
|
1405
1423
|
"""
|
1406
|
-
# if node not in self.get_active_nodes():
|
1407
|
-
# node = next((key for key, value in self._dct_node_addr_name.items() if value == node), node)
|
1408
1424
|
result = None
|
1409
|
-
if node in self.
|
1425
|
+
if node in self._dct_node_last_seen_time.keys():
|
1410
1426
|
# node seems to be already an address
|
1411
1427
|
result = node
|
1428
|
+
elif node in self.__dct_node_eth_addr_to_node_addr.keys():
|
1429
|
+
# node is an eth address
|
1430
|
+
result = self.__dct_node_eth_addr_to_node_addr.get(node, None)
|
1412
1431
|
else:
|
1413
1432
|
# maybe node is a name
|
1414
1433
|
aliases = self.__aliases_to_addresses()
|
@@ -1791,9 +1810,9 @@ class GenericSession(BaseDecentrAIObject):
|
|
1791
1810
|
return self.__get_node_address(name)
|
1792
1811
|
|
1793
1812
|
|
1794
|
-
def
|
1813
|
+
def get_node_alias(self, node_addr):
|
1795
1814
|
"""
|
1796
|
-
Get the
|
1815
|
+
Get the alias of a node.
|
1797
1816
|
|
1798
1817
|
Parameters
|
1799
1818
|
----------
|
@@ -1805,7 +1824,39 @@ class GenericSession(BaseDecentrAIObject):
|
|
1805
1824
|
str
|
1806
1825
|
The name of the node.
|
1807
1826
|
"""
|
1808
|
-
return self.
|
1827
|
+
return self.__dct_node_address_to_alias.get(node_addr, None)
|
1828
|
+
|
1829
|
+
def get_addr_by_eth_address(self, eth_address):
|
1830
|
+
"""
|
1831
|
+
Get the address of a node by its eth address.
|
1832
|
+
|
1833
|
+
Parameters
|
1834
|
+
----------
|
1835
|
+
eth_address : str
|
1836
|
+
The eth address of the node.
|
1837
|
+
|
1838
|
+
Returns
|
1839
|
+
-------
|
1840
|
+
str
|
1841
|
+
The address of the node.
|
1842
|
+
"""
|
1843
|
+
return self.__dct_node_eth_addr_to_node_addr.get(eth_address, None)
|
1844
|
+
|
1845
|
+
def get_eth_address_by_addr(self, node_addr):
|
1846
|
+
"""
|
1847
|
+
Get the eth address of a node by its address.
|
1848
|
+
|
1849
|
+
Parameters
|
1850
|
+
----------
|
1851
|
+
node_addr : str
|
1852
|
+
The address of the node.
|
1853
|
+
|
1854
|
+
Returns
|
1855
|
+
-------
|
1856
|
+
str
|
1857
|
+
The eth address of the node.
|
1858
|
+
"""
|
1859
|
+
return self.bc_engine.node_address_to_eth_address(node_addr)
|
1809
1860
|
|
1810
1861
|
def get_active_nodes(self):
|
1811
1862
|
"""
|
@@ -2173,14 +2224,15 @@ class GenericSession(BaseDecentrAIObject):
|
|
2173
2224
|
Parameters
|
2174
2225
|
----------
|
2175
2226
|
node : str
|
2176
|
-
The address or name of the
|
2227
|
+
The address or name of the Ratio1 edge node.
|
2177
2228
|
|
2178
2229
|
Returns
|
2179
2230
|
-------
|
2180
2231
|
bool
|
2181
2232
|
True if the node is online, False otherwise.
|
2182
2233
|
"""
|
2183
|
-
|
2234
|
+
node = self.__get_node_address(node)
|
2235
|
+
return node in self.get_active_nodes()
|
2184
2236
|
|
2185
2237
|
def create_chain_dist_custom_job(
|
2186
2238
|
self,
|
@@ -2846,7 +2898,7 @@ class GenericSession(BaseDecentrAIObject):
|
|
2846
2898
|
val = seconds_to_short_format(val)
|
2847
2899
|
elif key == PAYLOAD_DATA.NETMON_ADDRESS:
|
2848
2900
|
if self.bc_engine._remove_prefix(val) == self.bc_engine._remove_prefix(best_super):
|
2849
|
-
# again self.
|
2901
|
+
# again self.get_node_alias(best_super) might not work if using the hb data
|
2850
2902
|
best_super_alias = node_info.get(PAYLOAD_DATA.NETMON_EEID, None)
|
2851
2903
|
val = self.bc_engine._add_prefix(val)
|
2852
2904
|
if all_info:
|
naeural_client/base/pipeline.py
CHANGED
@@ -1541,11 +1541,24 @@ class Pipeline(BaseCodeChecker):
|
|
1541
1541
|
# end for instance
|
1542
1542
|
return
|
1543
1543
|
|
1544
|
+
@property
|
1545
|
+
def node_alias(self):
|
1546
|
+
"""
|
1547
|
+
Return the node alias of the pipeline.
|
1548
|
+
"""
|
1549
|
+
return self.session.get_node_alias(self.node_addr)
|
1550
|
+
|
1544
1551
|
@property
|
1545
1552
|
def node_id(self):
|
1546
1553
|
"""
|
1547
|
-
|
1554
|
+
Method alias for `node_alias`
|
1548
1555
|
"""
|
1549
|
-
return self.
|
1556
|
+
return self.node_alias
|
1550
1557
|
|
1558
|
+
@property
|
1559
|
+
def node_name(self):
|
1560
|
+
"""
|
1561
|
+
Method alias for `node_alias`
|
1562
|
+
"""
|
1563
|
+
return self.node_alias
|
1551
1564
|
|
naeural_client/const/payload.py
CHANGED
@@ -199,6 +199,7 @@ class PAYLOAD_DATA:
|
|
199
199
|
NETMON_STATUS_KEY = "working"
|
200
200
|
NETMON_STATUS_ONLINE = "ONLINE"
|
201
201
|
NETMON_ADDRESS = "address"
|
202
|
+
NETMON_ETH_ADDRESS = "eth_address"
|
202
203
|
NETMON_EEID = "eeid"
|
203
204
|
NETMON_LAST_REMOTE_TIME = 'last_remote_time'
|
204
205
|
NETMON_NODE_UTC = 'node_utc'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: naeural_client
|
3
|
-
Version: 2.7.
|
3
|
+
Version: 2.7.8
|
4
4
|
Summary: `naeural_client` is the Python SDK required for client app development for the Naeural Edge Protocol Edge Protocol framework
|
5
5
|
Project-URL: Homepage, https://github.com/NaeuralEdgeProtocol/naeural_client
|
6
6
|
Project-URL: Bug Tracker, https://github.com/NaeuralEdgeProtocol/naeural_client/issues
|
@@ -1,12 +1,12 @@
|
|
1
1
|
naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
|
2
|
-
naeural_client/_ver.py,sha256=
|
2
|
+
naeural_client/_ver.py,sha256=xyIpvn7b735D9Wb7uaQLhUG4S1REdX5ilj50twPH4lk,330
|
3
3
|
naeural_client/base_decentra_object.py,sha256=C4iwZTkhKNBS4VHlJs5DfElRYLo4Q9l1V1DNVSk1fyQ,4412
|
4
4
|
naeural_client/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
|
5
5
|
naeural_client/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
|
6
6
|
naeural_client/base/distributed_custom_code_presets.py,sha256=cvz5R88P6Z5V61Ce1vHVVh8bOkgXd6gve_vdESDNAsg,2544
|
7
|
-
naeural_client/base/generic_session.py,sha256=
|
7
|
+
naeural_client/base/generic_session.py,sha256=BdM28wRfDIqzAMOD3Msrtm8b-foDBo6X825MjyXGI5g,109812
|
8
8
|
naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
|
9
|
-
naeural_client/base/pipeline.py,sha256=
|
9
|
+
naeural_client/base/pipeline.py,sha256=SNl0QLJTbaP_mlwVm1p9Vwxo72Q1Bp2ls3rt1WGPg7c,58828
|
10
10
|
naeural_client/base/plugin_template.py,sha256=7YAFaND2iXoZLgtunjYkFf_TBGieFr3VdNLO3vCqzmM,138795
|
11
11
|
naeural_client/base/responses.py,sha256=ZKBZmRhYDv8M8mQ5C_ahGsQvtWH4b9ImRcuerQdZmNw,6937
|
12
12
|
naeural_client/base/transaction.py,sha256=bfs6td5M0fINgPQNxhrl_AUjb1YiilLDQ-Cd_o3OR_E,5146
|
@@ -40,7 +40,7 @@ naeural_client/const/environment.py,sha256=RpdDhDgB8NgRoFTk28eODigf9y0WcT9lul6mB
|
|
40
40
|
naeural_client/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
|
41
41
|
naeural_client/const/heartbeat.py,sha256=xHZBX_NzHTklwA2_AEKR0SGdlbavMT4nirqjQg8WlTU,2550
|
42
42
|
naeural_client/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
|
43
|
-
naeural_client/const/payload.py,sha256=
|
43
|
+
naeural_client/const/payload.py,sha256=u_FLn19EJCDo4UqVfUX9ExikFWE-YFEhkj-Ij8an0VQ,6600
|
44
44
|
naeural_client/default/__init__.py,sha256=ozU6CMMuWl0LhG8Ae3LrZ65a6tLrptfscVYGf83zjxM,46
|
45
45
|
naeural_client/default/instance/__init__.py,sha256=_cr6a9gProAZKL9_uz855q2pWt2jHwqE16ed8sm6V8I,653
|
46
46
|
naeural_client/default/instance/chain_dist_custom_job_01_plugin.py,sha256=QtHi3uXKsVs9eyMgbnvBVbMylErhV1Du4X2-7zDL7Y0,1915
|
@@ -84,8 +84,8 @@ naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_L
|
|
84
84
|
naeural_client/utils/config.py,sha256=QDrVywnhmf1k-sAb5jIBHZ_80TjNZk02uRG-t8mYLKQ,7413
|
85
85
|
naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
|
86
86
|
naeural_client/utils/oracle_sync/oracle_tester.py,sha256=GmZwu2JM9_UB2K-4rKB3o0RgWLqM-7Im6HwBnQLXmHI,25312
|
87
|
-
naeural_client-2.7.
|
88
|
-
naeural_client-2.7.
|
89
|
-
naeural_client-2.7.
|
90
|
-
naeural_client-2.7.
|
91
|
-
naeural_client-2.7.
|
87
|
+
naeural_client-2.7.8.dist-info/METADATA,sha256=14nrgXbF5gavIW1PCqmurhH5_7HD5lbrVIlo9BObw_E,12353
|
88
|
+
naeural_client-2.7.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
89
|
+
naeural_client-2.7.8.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
|
90
|
+
naeural_client-2.7.8.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
|
91
|
+
naeural_client-2.7.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|