naeural-client 2.5.10__py3-none-any.whl → 2.5.12__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.5.10"
1
+ __VER__ = "2.5.12"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -1374,7 +1374,8 @@ class GenericSession(BaseDecentrAIObject):
1374
1374
 
1375
1375
  def get_allowed_nodes(self):
1376
1376
  """
1377
- Get the list of all active Naeural Edge Protocol edge nodes to whom this session can send messages
1377
+ Get the list of all active Naeural Edge Protocol edge nodes to whom this
1378
+ ssion can send messages. This is based on the last heartbeat received from each individual node.
1378
1379
 
1379
1380
  Returns
1380
1381
  -------
@@ -1810,9 +1811,6 @@ class GenericSession(BaseDecentrAIObject):
1810
1811
  """
1811
1812
 
1812
1813
  ngrok_use_api = True
1813
-
1814
- # if isinstance(signature, str):
1815
-
1816
1814
 
1817
1815
  pipeline: WebappPipeline = self.create_pipeline(
1818
1816
  node=node,
@@ -1887,14 +1885,15 @@ class GenericSession(BaseDecentrAIObject):
1887
1885
  kwargs.pop('use_ngrok', None)
1888
1886
  kwargs.pop('ngrok_use_api', None)
1889
1887
 
1890
- # if isinstance(signature, str):
1891
-
1888
+ if ngrok_edge_label is None:
1889
+ raise ValueError("The `ngrok_edge_label` parameter is mandatory when creating a balanced web app, in order for all instances to respond to the same URL.")
1890
+
1892
1891
  pipelines, instances = [], []
1893
1892
 
1894
1893
  for node in nodes:
1895
1894
  self.P("Creating web app on node {}...".format(node), color='b')
1896
1895
  pipeline: WebappPipeline = self.create_pipeline(
1897
- node=nodes[0],
1896
+ node=node,
1898
1897
  name=name,
1899
1898
  pipeline_type=WebappPipeline,
1900
1899
  extra_debug=extra_debug,
@@ -2240,11 +2239,43 @@ class GenericSession(BaseDecentrAIObject):
2240
2239
  online_only=False,
2241
2240
  supervisors_only=False,
2242
2241
  min_supervisors=2,
2242
+ allowed_only=False,
2243
2243
  supervisor=None,
2244
2244
  ):
2245
2245
  """
2246
2246
  This function will return a Pandas dataframe known nodes in the network based on
2247
2247
  all the net-mon messages received so far.
2248
+
2249
+ Parameters
2250
+ ----------
2251
+
2252
+ timeout : int, optional
2253
+ The maximum time to wait for the desired number of supervisors to appear online.
2254
+ Defaults to 10.
2255
+
2256
+ online_only : bool, optional
2257
+ If True, will return only the online nodes. Defaults to False.
2258
+
2259
+ supervisors_only : bool, optional
2260
+ If True, will return only the supervisors. Defaults to False.
2261
+
2262
+ min_supervisors : int, optional
2263
+ The minimum number of supervisors to wait for. Defaults to 2.
2264
+
2265
+ allowed_only : bool, optional
2266
+ If True, will return only the allowed nodes. Defaults to False.
2267
+
2268
+ supervisor : str, optional
2269
+ The supervisor to wait for. Defaults to None.
2270
+
2271
+ Returns
2272
+ -------
2273
+
2274
+ dict
2275
+ A dictionary containing the report, the reporter and the number of supervisors.
2276
+
2277
+
2278
+
2248
2279
  """
2249
2280
  mapping = OrderedDict({
2250
2281
  'Address': PAYLOAD_DATA.NETMON_ADDRESS,
@@ -2254,13 +2285,16 @@ class GenericSession(BaseDecentrAIObject):
2254
2285
  'Last probe' : PAYLOAD_DATA.NETMON_LAST_REMOTE_TIME,
2255
2286
  'Zone' : PAYLOAD_DATA.NETMON_NODE_UTC,
2256
2287
  'Supervisor' : PAYLOAD_DATA.NETMON_IS_SUPERVISOR,
2288
+ 'Peered' : PAYLOAD_DATA.NETMON_WHITELIST,
2257
2289
  })
2258
2290
  reverse_mapping = {v: k for k, v in mapping.items()}
2259
2291
  res = OrderedDict()
2260
2292
  for k in mapping:
2261
2293
  res[k] = []
2294
+
2295
+ # the following loop will wait for the desired number of supervisors to appear online
2296
+ # for the current session
2262
2297
  start = tm()
2263
-
2264
2298
  while (tm() - start) < timeout:
2265
2299
  if supervisor is not None:
2266
2300
  if supervisor in self.__current_network_statuses:
@@ -2268,7 +2302,10 @@ class GenericSession(BaseDecentrAIObject):
2268
2302
  elif len(self.__current_network_statuses) >= min_supervisors:
2269
2303
  break
2270
2304
  sleep(0.1)
2305
+ elapsed = tm() - start
2271
2306
  # end while
2307
+ # done waiting for supervisors
2308
+
2272
2309
  if len(self.__current_network_statuses) > 0:
2273
2310
  best_info = {}
2274
2311
  best_super = None
@@ -2276,10 +2313,17 @@ class GenericSession(BaseDecentrAIObject):
2276
2313
  if len(net_info) > len(best_info):
2277
2314
  best_info = net_info
2278
2315
  best_super = supervisor
2316
+ best_super_alias = None
2279
2317
  # done found best supervisor
2280
2318
  for _, node_info in best_info.items():
2281
2319
  is_online = node_info.get(PAYLOAD_DATA.NETMON_STATUS_KEY, None) == PAYLOAD_DATA.NETMON_STATUS_ONLINE
2282
2320
  is_supervisor = node_info.get(PAYLOAD_DATA.NETMON_IS_SUPERVISOR, False)
2321
+ # the following will get the whitelist for the current inspected node
2322
+ # without calling self.get_allowed_nodes but instead using the netmon data
2323
+ whitelist = node_info.get(PAYLOAD_DATA.NETMON_WHITELIST, [])
2324
+ client_is_allowed = self.bc_engine.contains_current_address(whitelist)
2325
+ if allowed_only and not client_is_allowed:
2326
+ continue
2283
2327
  if online_only and not is_online:
2284
2328
  continue
2285
2329
  if supervisors_only and not is_supervisor:
@@ -2294,9 +2338,21 @@ class GenericSession(BaseDecentrAIObject):
2294
2338
  # convert val (seconds) to a human readable format
2295
2339
  val = seconds_to_short_format(val)
2296
2340
  elif key == PAYLOAD_DATA.NETMON_ADDRESS:
2341
+ if self.bc_engine._remove_prefix(val) == self.bc_engine._remove_prefix(best_super):
2342
+ # again self.get_node_name(best_super) might not work if using the hb data
2343
+ best_super_alias = node_info.get(PAYLOAD_DATA.NETMON_EEID, None)
2297
2344
  val = self.bc_engine._add_prefix(val)
2345
+ elif key == PAYLOAD_DATA.NETMON_WHITELIST:
2346
+ val = client_is_allowed
2298
2347
  res[column].append(val)
2299
2348
  # end for
2300
2349
  # end if
2301
2350
  pd.options.display.float_format = '{:.1f}'.format
2302
- return pd.DataFrame(res), best_super
2351
+ dct_result ={
2352
+ 'report' : pd.DataFrame(res),
2353
+ 'reporter' : best_super,
2354
+ 'reporter_alias' : best_super_alias,
2355
+ 'nr_super' : len(self.__current_network_statuses),
2356
+ 'elapsed' : elapsed,
2357
+ }
2358
+ return dct_result
naeural_client/bc/base.py CHANGED
@@ -847,10 +847,30 @@ class BaseBlockEngine:
847
847
  #### ####
848
848
  #############################################################################
849
849
 
850
+
851
+ def contains_current_address(self, lst_addresses):
852
+ """
853
+ Checks if the current address is in the list of addresses
854
+
855
+ Parameters
856
+ ----------
857
+ lst_addresses : list
858
+ the list of addresses.
859
+
860
+ Returns
861
+ -------
862
+ bool
863
+ True if the current address is in the list.
864
+
865
+ """
866
+ lst = [self._remove_prefix(x) for x in lst_addresses]
867
+ return self.address_no_prefix in lst
868
+
850
869
  @property
851
870
  def address(self):
852
871
  """Returns the public address"""
853
872
  return self.__address
873
+
854
874
 
855
875
  @property
856
876
  def address_no_prefix(self):
@@ -11,10 +11,12 @@ CLI_COMMANDS = {
11
11
  "nodes": {
12
12
  "func": get_nodes,
13
13
  "params": {
14
- "--all": "Get all known nodes flag", # DONE
15
- "--online" : "Get only online nodes flag", # DONE
16
- # "--peered": "Get only peered nodes"
17
- "--supervisor" : "Use a specific supervisor node"
14
+ ### use "flag" to indicate a boolean flag otherwise it will be
15
+ ### treated as a str parameter
16
+ "--all": "Get all known nodes flag", # DONE
17
+ "--online" : "Get only online nodes flag", # DONE
18
+ "--peered": "Get only peered nodes flag", # DONE
19
+ "--supervisor" : "Use a specific supervisor node"
18
20
  }
19
21
  },
20
22
  "supervisors": {
@@ -15,22 +15,20 @@ def get_nodes(args):
15
15
  log_with_color(f"Getting nodes from supervisor <{supervisor_addr}>...", color='b')
16
16
  from naeural_client import Session
17
17
  sess = Session(silent=not args.verbose)
18
- if args.all:
19
- df, supervisor = sess.get_network_known_nodes(supervisor=supervisor_addr)
20
- log_with_color(f"Network full map reported by <{supervisor}>:", color='b')
21
- log_with_color(f"{df}")
22
- elif args.online:
23
- df, supervisor = sess.get_network_known_nodes(
24
- online_only=True, supervisor=supervisor_addr
25
- )
26
- log_with_color(f"Online nodes reported by <{supervisor}>:", color='b')
27
- log_with_color(f"{df}")
28
- else:
29
- df, supervisor = sess.get_network_known_nodes(
30
- online_only=True, supervisor=supervisor_addr
31
- )
32
- log_with_color(f"Online nodes reported by <{supervisor}>:", color='b')
33
- log_with_color(f"{df}")
18
+ online_only = args.online or args.peered
19
+ allowed_only = args.peered
20
+
21
+ dct_info = sess.get_network_known_nodes(
22
+ online_only=online_only, allowed_only=allowed_only, supervisor=supervisor_addr
23
+ )
24
+ df = dct_info['report']
25
+ supervisor = dct_info['reporter']
26
+ super_alias = dct_info['reporter_alias']
27
+ nr_supers = dct_info['nr_super']
28
+ elapsed = dct_info['elapsed']
29
+ prefix = "Online n" if online_only else "N"
30
+ log_with_color(f"{prefix}odes reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s ({nr_supers} supervisors seen):", color='b')
31
+ log_with_color(f"{df}")
34
32
  return
35
33
 
36
34
 
@@ -42,8 +40,12 @@ def get_supervisors(args):
42
40
  log_with_color("Getting supervisors...", color='b')
43
41
  from naeural_client import Session
44
42
  sess = Session(silent=not args.verbose)
45
- df, supervisor = sess.get_network_known_nodes(online_only=True, supervisors_only=True)
46
- log_with_color(f"Supervisors reported by <{supervisor}>", color='b')
43
+ dct_info = sess.get_network_known_nodes(online_only=True, supervisors_only=True)
44
+ df = dct_info['report']
45
+ supervisor = dct_info['reporter']
46
+ super_alias = dct_info['reporter_alias']
47
+ elapsed = dct_info['elapsed']
48
+ log_with_color(f"Supervisors reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s", color='b')
47
49
  log_with_color(f"{df}")
48
50
  return
49
51
 
@@ -6,6 +6,7 @@ class PLUGIN_SIGNATURES:
6
6
  NET_MON_01 = 'NET_MON_01'
7
7
  VIEW_SCENE_01 = 'VIEW_SCENE_01'
8
8
  CUSTOM_WEBAPI_01 = 'CUSTOM_CODE_FASTAPI_01'
9
+ GENERIC_WEB_APP = 'GENERIC_WEB_APP'
9
10
  CHAIN_DIST_CUSTOM_JOB_01 = 'PROCESS_REAL_TIME_COLLECTED_DATA_CUSTOM_EXEC_CHAIN_DIST'
10
11
  TELEGRAM_BASIC_BOT_01 = 'TELEGRAM_BASIC_BOT_01'
11
12
  TELEGRAM_CONVERSATIONAL_BOT_01 = 'TELEGRAM_CONVERSATIONAL_BOT_01'
@@ -204,6 +204,7 @@ class PAYLOAD_DATA:
204
204
  NETMON_NODE_UTC = 'node_utc'
205
205
  NETMON_LAST_SEEN = 'last_seen_sec'
206
206
  NETMON_IS_SUPERVISOR = 'is_supervisor'
207
+ NETMON_WHITELIST = 'whitelist'
207
208
 
208
209
 
209
210
  class NET_CONFIG:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.5.10
3
+ Version: 2.5.12
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,10 +1,10 @@
1
1
  naeural_client/__init__.py,sha256=GP8WSrn87sjTPO-QRNL2PG8JK5Mixbiea_HrtbG8RAQ,592
2
- naeural_client/_ver.py,sha256=7XEHOK0i9HkX7jfaACmmU3j4R-qJDilrxPE0cmy7IuI,331
2
+ naeural_client/_ver.py,sha256=Etnrsys-9WQ20DaPWxNocvHa66Vsrdaj5yjHBHUTtzA,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=3pvPZCIiygD-QWggmWUOZWj52o6la5koEYd2R-OF9YQ,85692
7
+ naeural_client/base/generic_session.py,sha256=6dc7oiKSw0Tc1pOh1WiE4XI8qX-hch-EKLozqsBiJ7o,88092
8
8
  naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
9
9
  naeural_client/base/pipeline.py,sha256=b4uNHrEIOlAtw4PGUx20dxwBhDck5__SrVXaHcSi8ZA,58251
10
10
  naeural_client/base/plugin_template.py,sha256=qGaXByd_JZFpjvH9GXNbT7KaitRxIJB6-1IhbKrZjq4,138123
@@ -14,15 +14,15 @@ naeural_client/base/webapp_pipeline.py,sha256=QmPLVmhP0CPdi0YuvbZEH4APYz2Amtw3gy
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=ZXJkP0ainztIf0ehUOBUrqOr6msrfCyF8MvAklTxoDo,31773
17
+ naeural_client/bc/base.py,sha256=Uzpv0_YAM-lVV0mRJkt2cCy3z107BI50R-xWf-i32hw,32184
18
18
  naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  naeural_client/bc/ec.py,sha256=mWjodWCRgC3omVXOA9jtNdtPVNn2kMKV3Dcjt9oFUCQ,22974
20
20
  naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1gPULtJNSYUpG_YFkYaMKU,1337
22
22
  naeural_client/cli/README.md,sha256=WPdI_EjzAbUW1aPyj1sSR8rLydcJKZtoiaEtklQrjHo,74
23
23
  naeural_client/cli/cli.py,sha256=GyQhw16LrCbXU0JLH0HlbyYvKqa15K5RIhQ-Pgi7Gy4,3752
24
- naeural_client/cli/cli_commands.py,sha256=BtByinaxFvThyQdeu8Moz2aMioR5MW5GTiI1bGjbfwQ,1392
25
- naeural_client/cli/nodes.py,sha256=Q26sJpDCOd0oqpNonqEoCc1EcLVnf2CaGFzrG1wyzhA,2363
24
+ naeural_client/cli/cli_commands.py,sha256=Q4BGaqx162aFgVu6PiTEqEpx1-nzeH5Alpb6oKRNQ38,1519
25
+ naeural_client/cli/nodes.py,sha256=aCbSDFhTnub18LdrOPzu3kvx6acaBqHRgmyAdgqblP8,2459
26
26
  naeural_client/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
27
27
  naeural_client/code_cheker/base.py,sha256=lT5DRIFO5rqzsMNCmdMRfkAeevmezozehyfgmhnKpuI,19074
28
28
  naeural_client/code_cheker/checker.py,sha256=QWupeM7ToancVIq1tRUxRNUrI8B5l5eoY0kDU4-O5aE,7365
@@ -31,14 +31,14 @@ naeural_client/comm/amqp_wrapper.py,sha256=hzj6ih07DnLQy2VSfA88giDIFHaCp9uSdGLTA
31
31
  naeural_client/comm/mqtt_wrapper.py,sha256=Ig3bFZkCbWd4y_Whn2PPa91Z3aLgNbNPau6Tn5yLPZ8,16167
32
32
  naeural_client/const/README.md,sha256=6OHesr-f5NBuuJGryEoi_TCu2XdlhfQYlDKx_IJoXeg,177
33
33
  naeural_client/const/__init__.py,sha256=OtrSiHyTzrie5dyC1gWrYXYmg5cVMdwe0gxAlrHXCLg,466
34
- naeural_client/const/apps.py,sha256=aZ9oiBT8MC1Vm7e0TyerRvQ7z4m0-GHR67BXdLnv5lE,573
34
+ naeural_client/const/apps.py,sha256=gIONTZUkqPveu3DwelyJWpbFMeIR9l6DlaNg-xEfK1A,611
35
35
  naeural_client/const/base.py,sha256=-NeZPwE0JrbTHmlI9BOmgzaGu5jUZHl9vOZ4hhh_QQo,3100
36
36
  naeural_client/const/comms.py,sha256=La6JXWHexH8CfcBCKyT4fCIoeaoZlcm7KtZ57ab4ZgU,2201
37
37
  naeural_client/const/environment.py,sha256=iytmTDgbOjvORPwHQmc0K0r-xJx7dnnzNnqAJJiFCDA,870
38
38
  naeural_client/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
39
39
  naeural_client/const/heartbeat.py,sha256=jGHmKfeHTFOXJaKUT3o_ocnQyF-EpcLeunW-ifkYKfU,2534
40
40
  naeural_client/const/misc.py,sha256=Y6x00YDtY1_nAk4OvikCLlfp8ggn11WQYTBGYzFlJPk,211
41
- naeural_client/const/payload.py,sha256=fHhhdSv1o_5Ldy72jO7m3YZtMmJOpOHaVhfjbNCuuzo,6446
41
+ naeural_client/const/payload.py,sha256=vHKxSrPXnfBTBwD_xp9Aw7nue0_gxz4r01YjXRYiTIM,6479
42
42
  naeural_client/default/__init__.py,sha256=ozU6CMMuWl0LhG8Ae3LrZ65a6tLrptfscVYGf83zjxM,46
43
43
  naeural_client/default/instance/__init__.py,sha256=w1de6OMj9a5GPGF-Wl1b_I_YAy9fWBEss2QnyPPyaB0,546
44
44
  naeural_client/default/instance/chain_dist_custom_job_01_plugin.py,sha256=QtHi3uXKsVs9eyMgbnvBVbMylErhV1Du4X2-7zDL7Y0,1915
@@ -81,8 +81,8 @@ naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uw
81
81
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
82
82
  naeural_client/utils/config.py,sha256=aUVyi5rZjvnbUwM5mmj0E2IHvURdrlHSgleqZvJBNuU,5202
83
83
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
84
- naeural_client-2.5.10.dist-info/METADATA,sha256=N10XAff7Is_YnSS9w5HVVuQjUNNhOR1KsUI1h2wEoV0,14494
85
- naeural_client-2.5.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
- naeural_client-2.5.10.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
- naeural_client-2.5.10.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
- naeural_client-2.5.10.dist-info/RECORD,,
84
+ naeural_client-2.5.12.dist-info/METADATA,sha256=n1wMrq38BVALLSAHAfuNpsPRj7m5slgO7UgWOy8HGR8,14494
85
+ naeural_client-2.5.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
+ naeural_client-2.5.12.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
+ naeural_client-2.5.12.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
+ naeural_client-2.5.12.dist-info/RECORD,,