naeural-client 2.6.32__py3-none-any.whl → 2.6.33__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 CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "2.6.32"
1
+ __VER__ = "2.6.33"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -571,6 +571,11 @@ class GenericSession(BaseDecentrAIObject):
571
571
  """
572
572
  node_whitelist = dict_msg.get(PAYLOAD_DATA.NETMON_WHITELIST, [])
573
573
  node_secured = dict_msg.get(PAYLOAD_DATA.NETMON_NODE_SECURED, False)
574
+ node_online = dict_msg.get(PAYLOAD_DATA.NETMON_STATUS_KEY) == PAYLOAD_DATA.NETMON_STATUS_ONLINE
575
+ node_alias = dict_msg.get(PAYLOAD_DATA.NETMON_EEID, None)
576
+
577
+ if node_online:
578
+ self.__track_online_node(node_addr, node_alias)
574
579
 
575
580
  client_is_allowed = self.bc_engine.contains_current_address(node_whitelist)
576
581
  can_send = not node_secured or client_is_allowed or self.bc_engine.address == node_addr
@@ -758,7 +763,10 @@ class GenericSession(BaseDecentrAIObject):
758
763
  nr_peers = sum([v for k, v in self._dct_can_send_to_node.items()])
759
764
  if nr_peers > 0 and not self.__at_least_one_node_peered:
760
765
  self.__at_least_one_node_peered = True
761
- self.P(f"Received {PLUGIN_SIGNATURES.NET_MON_01} from {sender_addr}, so far {nr_peers} peers that allow me: {json.dumps(self._dct_can_send_to_node, indent=2)}", color='g')
766
+ self.P(
767
+ f"Received {PLUGIN_SIGNATURES.NET_MON_01} from {sender_addr}, so far {nr_peers} peers that allow me: {json.dumps(self._dct_can_send_to_node, indent=2)}",
768
+ color='g'
769
+ )
762
770
  # end for each node in network map
763
771
  # end if current_network is valid
764
772
  # end if NET_MON_01
@@ -912,7 +920,15 @@ class GenericSession(BaseDecentrAIObject):
912
920
  self.__running_main_loop_thread = True
913
921
  self._main_loop_thread.start()
914
922
 
915
- # we could wait here for `self.__at_least_one_node_peered` but is not a good idea
923
+ start_wait = tm()
924
+ while not self.__at_least_a_netmon_received:
925
+ if (tm() - start_wait) > self.START_TIMEOUT:
926
+ msg = "Timeout waiting for NET_MON_01 message. No connections. Exiting..."
927
+ self.P(msg, color='r', show=True)
928
+ break
929
+ sleep(0.1)
930
+ if self.__at_least_a_netmon_received:
931
+ self.P("Received at least one NET_MON_01 message. Resuming the main thread...", color='g')
916
932
  return
917
933
 
918
934
  def __handle_open_transactions(self):
@@ -1061,11 +1077,6 @@ class GenericSession(BaseDecentrAIObject):
1061
1077
  self.__maybe_reconnect()
1062
1078
  self.__handle_open_transactions()
1063
1079
  sleep(0.1)
1064
- if not self.__at_least_a_netmon_received:
1065
- if (tm() - self.__start_main_loop_time) > self.START_TIMEOUT:
1066
- msg = "Timeout waiting for NET_MON_01 message. Exiting..."
1067
- self.P(msg, color='r', show=True)
1068
- break
1069
1080
  # end while self.running
1070
1081
 
1071
1082
  self.P("Main loop thread exiting...", verbosity=2)
@@ -1107,6 +1118,7 @@ class GenericSession(BaseDecentrAIObject):
1107
1118
  bool_loop_condition = isinstance(wait, bool) and wait
1108
1119
  number_loop_condition = isinstance(wait, (int, float)) and (wait == 0 or (tm() - _start_timer) < wait)
1109
1120
  callable_loop_condition = callable(wait) and wait()
1121
+ self.P("Exiting loop...", verbosity=2)
1110
1122
  except KeyboardInterrupt:
1111
1123
  self.P("CTRL+C detected. Stopping loop.", color='r', verbosity=1)
1112
1124
 
@@ -1139,6 +1151,7 @@ class GenericSession(BaseDecentrAIObject):
1139
1151
  bool_loop_condition = isinstance(wait, bool) and wait
1140
1152
  number_loop_condition = isinstance(wait, (int, float)) and (wait == 0 or (tm() - _start_timer) < wait)
1141
1153
  callable_loop_condition = callable(wait) and wait()
1154
+ self.P("Exiting loop...", verbosity=2)
1142
1155
  except KeyboardInterrupt:
1143
1156
  self.P("CTRL+C detected. Stopping loop.", color='r', verbosity=1)
1144
1157
 
@@ -1762,7 +1775,7 @@ class GenericSession(BaseDecentrAIObject):
1762
1775
  List of addresses of all the Naeural Edge Protocol edge nodes that are considered online
1763
1776
 
1764
1777
  """
1765
- return [k for k, v in self._dct_node_last_seen_time.items() if tm() - v < self.online_timeout]
1778
+ return [k for k, v in self._dct_node_last_seen_time.items() if (tm() - v) < self.online_timeout]
1766
1779
 
1767
1780
  def get_allowed_nodes(self):
1768
1781
  """
@@ -2171,7 +2184,7 @@ class GenericSession(BaseDecentrAIObject):
2171
2184
  *,
2172
2185
  node,
2173
2186
  name,
2174
- signature,
2187
+ signature=PLUGIN_SIGNATURES.CUSTOM_WEBAPI_01,
2175
2188
  ngrok_edge_label=None,
2176
2189
  endpoints=None,
2177
2190
  use_ngrok=True,
@@ -870,8 +870,11 @@ class Pipeline(BaseCodeChecker):
870
870
  Exception
871
871
  Plugin instance already exists.
872
872
  """
873
+ from naeural_client.default.instance import REVERSE_MAP
874
+
873
875
  if isinstance(signature, str):
874
876
  str_signature = signature.upper()
877
+ signature = REVERSE_MAP.get(str_signature, str_signature)
875
878
  else:
876
879
  plugin_template = signature
877
880
  str_signature = plugin_template.signature.upper()
@@ -1079,7 +1082,8 @@ class Pipeline(BaseCodeChecker):
1079
1082
  self.__apply_staged_config(verbose=verbose)
1080
1083
  self.__apply_staged_instances_config(verbose=verbose)
1081
1084
 
1082
- self.P("Pipeline <{}> deployed".format(self.name), color="g")
1085
+ # TODO: must add "deployed" message to proper location
1086
+ self.P("Pipeline <{}> deploy initiated...".format(self.name))
1083
1087
 
1084
1088
  if with_confirmation and not wait_confirmation:
1085
1089
  return transactions
@@ -1222,11 +1226,12 @@ class Pipeline(BaseCodeChecker):
1222
1226
  Exception
1223
1227
  The pipeline does not contain the desired instance.
1224
1228
  """
1225
-
1229
+ from naeural_client.default.instance import REVERSE_MAP
1226
1230
  # search for the instance in the list
1227
1231
  plugin_template = None
1228
1232
  if isinstance(signature, str):
1229
1233
  str_signature = signature.upper()
1234
+ signature = REVERSE_MAP.get(str_signature, str_signature)
1230
1235
  else:
1231
1236
  plugin_template = signature
1232
1237
  str_signature = plugin_template.signature.upper()
@@ -109,6 +109,8 @@ class WebappPipeline(Pipeline):
109
109
  while self.ngrok_url is None:
110
110
  elapsed = time.time() - start
111
111
  if elapsed > timeout:
112
- raise Exception("Timeout waiting for ngrok url")
112
+ msg = "Timeout waiting for ngrok url"
113
+ self.P(msg, color="red")
114
+ raise Exception(msg)
113
115
  # return the ngrok url
114
116
  return self.ngrok_url
naeural_client/bc/base.py CHANGED
@@ -573,8 +573,9 @@ class BaseBlockEngine:
573
573
  #endif
574
574
  #endfor
575
575
  if len(lst_addresses) > 0:
576
- existing_addrs, existing_names = self._load_and_maybe_create_allowed(return_names=True)
577
- existing_addrs = [self.maybe_add_prefix(x) for x in existing_addrs]
576
+ existing_addrs, existing_names = self._load_and_maybe_create_allowed(
577
+ return_names=True, return_prefix=True
578
+ )
578
579
  for addr, name in zip(lst_addresses, lst_names):
579
580
  if addr not in existing_addrs:
580
581
  changed = True
@@ -629,7 +630,9 @@ class BaseBlockEngine:
629
630
  )
630
631
  errors = True
631
632
  else:
632
- lst_final.append(self.maybe_add_prefix(allowed))
633
+ if return_prefix:
634
+ allowed = self.maybe_add_prefix(allowed)
635
+ lst_final.append(allowed)
633
636
  lst_lines.append(allowed_tuple)
634
637
  lst_names.append(name)
635
638
  if errors:
@@ -944,7 +947,7 @@ class BaseBlockEngine:
944
947
  True if the current address is in the list.
945
948
 
946
949
  """
947
- lst = [self._remove_prefix(x) for x in lst_addresses]
950
+ lst = [self._remove_prefix(x) for x in lst_addresses if x is not None]
948
951
  return self.address_no_prefix in lst
949
952
 
950
953
  @property
@@ -960,8 +963,8 @@ class BaseBlockEngine:
960
963
 
961
964
  @property
962
965
  def allowed_list(self):
963
- """Returns the allowed command senders for the current node"""
964
- return self._load_and_maybe_create_allowed()
966
+ """Returns the allowed command senders (non-prefixed) for the current node"""
967
+ return self._load_and_maybe_create_allowed(return_names=False, return_prefix=False)
965
968
 
966
969
  @property
967
970
  def whitelist(self):
@@ -14,3 +14,8 @@ class PLUGIN_TYPES:
14
14
  CUSTOM_WEBAPI_01 = CustomWebapi01
15
15
  CHAIN_DIST_CUSTOM_JOB_01 = ChainDistCustomJob01
16
16
  TELEGRAM_BASIC_BOT_01 = BasicTelegramBot01
17
+
18
+
19
+ REVERSE_MAP = {
20
+ x.signature: x for x in PLUGIN_TYPES.__dict__.values() if hasattr(x, "signature")
21
+ }
@@ -139,6 +139,10 @@ def reset_config(*larg, keep_existing=False, **kwargs):
139
139
  if not keep_existing:
140
140
  target_pem.unlink()
141
141
  log_with_color(f"Deleted {target_pem}. A default key will be generated.", color='b')
142
+ #end if
143
+ #endif pem exists
144
+ #end if local pem exists
145
+ show_version()
142
146
  return
143
147
 
144
148
  def show_address(args):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.6.32
3
+ Version: 2.6.33
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,20 +1,20 @@
1
1
  naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=lJOZ0HCGsKGDzT1uT-izNuro_E4D0bjxQ5ymKSXoG18,331
2
+ naeural_client/_ver.py,sha256=LmPOqbSjTBCD9bB2yLsx239p0IDIXEobXCX_8g6ND3c,331
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=joF01ZoIt6QCSg7hDkg5M8ZCmKubpbQVh-plqi6GA9E,105079
7
+ naeural_client/base/generic_session.py,sha256=ACDABiJR0mY4U4wQdGj82IrnxBwC_8RUDSr6HeSMOlw,105598
8
8
  naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
9
- naeural_client/base/pipeline.py,sha256=b4uNHrEIOlAtw4PGUx20dxwBhDck5__SrVXaHcSi8ZA,58251
9
+ naeural_client/base/pipeline.py,sha256=EvESG5UH5GwyAZbJWJk1irTzGYBuOUjl-8KjkCdgLVI,58574
10
10
  naeural_client/base/plugin_template.py,sha256=qGaXByd_JZFpjvH9GXNbT7KaitRxIJB6-1IhbKrZjq4,138123
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
13
- naeural_client/base/webapp_pipeline.py,sha256=QmPLVmhP0CPdi0YuvbZEH4APYz2Amtw3gyOu4bVodYA,2740
13
+ naeural_client/base/webapp_pipeline.py,sha256=ZNGqZ36DY076XVDfGu2Q61kCt3kxIJ4Mi4QbPZuDVn0,2791
14
14
  naeural_client/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
15
15
  naeural_client/base/payload/payload.py,sha256=x-au7l67Z_vfn_4R2C_pjZCaFuUVXHngJiGOfIAYVdE,2690
16
16
  naeural_client/bc/__init__.py,sha256=FQj23D1PrY06NUOARiKQi4cdj0-VxnoYgYDEht8lpr8,158
17
- naeural_client/bc/base.py,sha256=c7zYNJb9aaGYgRoVkCHOLjrZjp7aCACyCIyIP69Obuc,42177
17
+ naeural_client/bc/base.py,sha256=kvPRvjKyFjjwa3GZF6BYbcITwoAfjtc0k0DP0FXpfgw,42274
18
18
  naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  naeural_client/bc/ec.py,sha256=qI8l7YqiS4MNftlx-tF7IZUswrSeQc7KMn5OZ0fEaJs,23370
20
20
  naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -41,7 +41,7 @@ naeural_client/const/heartbeat.py,sha256=xHZBX_NzHTklwA2_AEKR0SGdlbavMT4nirqjQg8
41
41
  naeural_client/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
42
42
  naeural_client/const/payload.py,sha256=cKfl2RO1VowrLM0KlYoZQIcwFs_mOCC9xzEZtj0pS9E,6563
43
43
  naeural_client/default/__init__.py,sha256=ozU6CMMuWl0LhG8Ae3LrZ65a6tLrptfscVYGf83zjxM,46
44
- naeural_client/default/instance/__init__.py,sha256=w1de6OMj9a5GPGF-Wl1b_I_YAy9fWBEss2QnyPPyaB0,546
44
+ naeural_client/default/instance/__init__.py,sha256=_cr6a9gProAZKL9_uz855q2pWt2jHwqE16ed8sm6V8I,653
45
45
  naeural_client/default/instance/chain_dist_custom_job_01_plugin.py,sha256=QtHi3uXKsVs9eyMgbnvBVbMylErhV1Du4X2-7zDL7Y0,1915
46
46
  naeural_client/default/instance/custom_webapi_01_plugin.py,sha256=EEjW9c2EQatMktOjO5picyDYDSrppc6_TmMNI8lgFeA,4784
47
47
  naeural_client/default/instance/net_mon_01_plugin.py,sha256=u85i2AiYHkLJnam0wOx-m71hlp0EYyNtk3JwbkOrvHg,1208
@@ -80,11 +80,11 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
80
80
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
81
81
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
82
82
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
83
- naeural_client/utils/config.py,sha256=v7xHikr6Z5Sbvf3opYeMhYzGWD2pe0HlRwa-aGJzUh8,6323
83
+ naeural_client/utils/config.py,sha256=Ub5sw3NG6wskAF5C4s0WU0rzXHVLy70ZTRU0W8HUGTM,6403
84
84
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
85
85
  naeural_client/utils/oracle_sync/multiple_requests.py,sha256=GLzROGZ0gI4d1PVWgW_JBUYZjEL4LqZvHvwelxDiPW4,20892
86
- naeural_client-2.6.32.dist-info/METADATA,sha256=EVBTuCxaqYaN2J1KKk3LK8Bioiyglhitn0_lOz0w6DI,12354
87
- naeural_client-2.6.32.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
88
- naeural_client-2.6.32.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
89
- naeural_client-2.6.32.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
90
- naeural_client-2.6.32.dist-info/RECORD,,
86
+ naeural_client-2.6.33.dist-info/METADATA,sha256=32uUFJQMGhRnZMLgonWIN6o02gT-mG968NNaVwcIni4,12354
87
+ naeural_client-2.6.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
88
+ naeural_client-2.6.33.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
89
+ naeural_client-2.6.33.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
90
+ naeural_client-2.6.33.dist-info/RECORD,,