naeural-client 2.5.22__py3-none-any.whl → 2.5.24__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
naeural_client/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "2.5.22"
1
+ __VER__ = "2.5.24"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -14,7 +14,7 @@ from ..bc import DefaultBlockEngine, _DotDict
14
14
  from ..const import (
15
15
  COMMANDS, ENVIRONMENT, HB, PAYLOAD_DATA, STATUS_TYPE,
16
16
  PLUGIN_SIGNATURES, DEFAULT_PIPELINES,
17
- BLOCKCHAIN_CONFIG
17
+ BLOCKCHAIN_CONFIG, SESSION_CT
18
18
  )
19
19
  from ..const import comms as comm_ct
20
20
  from ..io_formatter import IOFormatterWrapper
@@ -2255,6 +2255,7 @@ class GenericSession(BaseDecentrAIObject):
2255
2255
  min_supervisors=2,
2256
2256
  allowed_only=False,
2257
2257
  supervisor=None,
2258
+ df_only=False,
2258
2259
  ):
2259
2260
  """
2260
2261
  This function will return a Pandas dataframe known nodes in the network based on
@@ -2282,6 +2283,9 @@ class GenericSession(BaseDecentrAIObject):
2282
2283
  supervisor : str, optional
2283
2284
  The supervisor to wait for. Defaults to None.
2284
2285
 
2286
+ df_only : bool, optional
2287
+ If True, will return only the Pandas dataframe. Defaults to False.
2288
+
2285
2289
  Returns
2286
2290
  -------
2287
2291
 
@@ -2324,10 +2328,11 @@ class GenericSession(BaseDecentrAIObject):
2324
2328
  elapsed = tm() - start
2325
2329
  # end while
2326
2330
  # done waiting for supervisors
2331
+ best_super = 'ERROR'
2332
+ best_super_alias = 'ERROR'
2327
2333
 
2328
2334
  if len(self.__current_network_statuses) > 0:
2329
2335
  best_info = {}
2330
- best_super = None
2331
2336
  for supervisor, net_info in self.__current_network_statuses.items():
2332
2337
  if len(net_info) > len(best_info):
2333
2338
  best_info = net_info
@@ -2368,10 +2373,12 @@ class GenericSession(BaseDecentrAIObject):
2368
2373
  # end if
2369
2374
  pd.options.display.float_format = '{:.1f}'.format
2370
2375
  dct_result = _DotDict({
2371
- 'report' : pd.DataFrame(res),
2372
- 'reporter' : best_super,
2373
- 'reporter_alias' : best_super_alias,
2374
- 'nr_super' : len(self.__current_network_statuses),
2375
- 'elapsed' : elapsed,
2376
+ SESSION_CT.NETSTATS_REPORT : pd.DataFrame(res),
2377
+ SESSION_CT.NETSTATS_REPORTER : best_super,
2378
+ SESSION_CT.NETSTATS_REPORTER_ALIAS : best_super_alias,
2379
+ SESSION_CT.NETSTATS_NR_SUPERVISORS : len(self.__current_network_statuses),
2380
+ SESSION_CT.NETSTATS_ELAPSED : elapsed,
2376
2381
  })
2382
+ if df_only:
2383
+ return dct_result[SESSION_CT.NETSTATS_REPORT]
2377
2384
  return dct_result
naeural_client/cli/cli.py CHANGED
@@ -98,17 +98,18 @@ def main():
98
98
  """
99
99
  try:
100
100
  # Initialize configuration if necessary
101
- maybe_init_config()
102
-
103
- # Build the CLI parser
104
- parser = build_parser()
105
- args = parser.parse_args()
106
-
107
- # Check if a command function is provided
108
- if hasattr(args, "func"):
109
- args.func(args) # Pass parsed arguments to the command function
110
- else:
111
- parser.print_help()
101
+ initialized = maybe_init_config()
102
+
103
+ if initialized:
104
+ # Build the CLI parser
105
+ parser = build_parser()
106
+ args = parser.parse_args()
107
+
108
+ # Check if a command function is provided
109
+ if hasattr(args, "func"):
110
+ args.func(args) # Pass parsed arguments to the command function
111
+ else:
112
+ parser.print_help()
112
113
 
113
114
  except Exception as e:
114
115
  # Handle unexpected errors gracefully
@@ -1,6 +1,30 @@
1
+ from time import time
1
2
  from naeural_client.utils.config import log_with_color
3
+ from naeural_client.const import SESSION_CT
2
4
 
3
5
 
6
+ def _get_netstats(
7
+ silent=True,
8
+ online_only=False,
9
+ allowed_only=False,
10
+ supervisor=None,
11
+ supervisors_only=False,
12
+ ):
13
+ t1 = time()
14
+ from naeural_client import Session
15
+ sess = Session(silent=silent)
16
+ dct_info = sess.get_network_known_nodes(
17
+ online_only=online_only, allowed_only=allowed_only, supervisor=supervisor,
18
+ supervisors_only=supervisors_only,
19
+ )
20
+ df = dct_info[SESSION_CT.NETSTATS_REPORT]
21
+ supervisor = dct_info[SESSION_CT.NETSTATS_REPORTER]
22
+ super_alias = dct_info[SESSION_CT.NETSTATS_REPORTER_ALIAS]
23
+ nr_supers = dct_info[SESSION_CT.NETSTATS_NR_SUPERVISORS]
24
+ _elapsed = dct_info[SESSION_CT.NETSTATS_ELAPSED] # computed on call
25
+ elapsed = time() - t1 # elapsed=_elapsed
26
+ return df, supervisor, super_alias, nr_supers, elapsed
27
+
4
28
  def get_nodes(args):
5
29
  """
6
30
  This function is used to get the information about the nodes and it will perform the following:
@@ -13,22 +37,21 @@ def get_nodes(args):
13
37
  supervisor_addr = args.supervisor
14
38
  if args.verbose:
15
39
  log_with_color(f"Getting nodes from supervisor <{supervisor_addr}>...", color='b')
16
- from naeural_client import Session
17
- sess = Session(silent=not args.verbose)
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
40
+
41
+ res = _get_netstats(
42
+ silent=not args.verbose,
43
+ online_only=args.online or args.peered,
44
+ allowed_only=args.peered,
45
+ supervisor=supervisor_addr,
23
46
  )
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}")
47
+ df, supervisor, super_alias, nr_supers, elapsed = res
48
+
49
+ prefix = "Online n" if (args.online or args.peered) else "N"
50
+ if supervisor == "ERROR":
51
+ log_with_color(f"No supervisors or no comms available in {elapsed:.1f}s. Please check your settings.", color='r')
52
+ else:
53
+ log_with_color(f"{prefix}odes reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s ({nr_supers} supervisors seen):", color='b')
54
+ log_with_color(f"{df}")
32
55
  return
33
56
 
34
57
 
@@ -38,15 +61,19 @@ def get_supervisors(args):
38
61
  """
39
62
  if args.verbose:
40
63
  log_with_color("Getting supervisors...", color='b')
41
- from naeural_client import Session
42
- sess = Session(silent=not args.verbose)
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')
49
- log_with_color(f"{df}")
64
+
65
+ res = _get_netstats(
66
+ silent=not args.verbose,
67
+ online_only=True,
68
+ supervisors_only=True,
69
+ )
70
+ df, supervisor, super_alias, nr_supers, elapsed = res
71
+
72
+ if supervisor == "ERROR":
73
+ log_with_color(f"No supervisors or no comms available in {elapsed:.1f}s. Please check your settings.", color='r')
74
+ else:
75
+ log_with_color(f"Supervisors reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s", color='b')
76
+ log_with_color(f"{df}")
50
77
  return
51
78
 
52
79
 
@@ -1,4 +1,4 @@
1
- from .misc import COLORS, WEEKDAYS_SHORT
1
+ from .misc import COLORS, WEEKDAYS_SHORT, SESSION_CT
2
2
  from . import comms as COMMS
3
3
  from . import base as BASE_CT
4
4
  from . import payload as PAYLOAD_CT
@@ -18,3 +18,13 @@ WEEKDAYS_SHORT = [
18
18
  'SAT',
19
19
  'SUN'
20
20
  ]
21
+
22
+
23
+ class SESSION_CT:
24
+ NETSTATS_REPORT = 'report'
25
+ NETSTATS_REPORTER = 'reporter'
26
+ NETSTATS_REPORTER_ALIAS = 'reporter_alias'
27
+ NETSTATS_NR_SUPERVISORS = 'nr_super'
28
+ NETSTATS_ELAPSED = 'elapsed'
29
+
30
+
@@ -181,10 +181,12 @@ def load_user_defined_config(verbose=False):
181
181
  def maybe_init_config():
182
182
  """
183
183
  Initializes the configuration if it doesn't exist yet.
184
+
185
+ TODO: in v3+ this will be migrated to a online authentication process.
184
186
  """
185
187
  config_file = get_user_config_file()
186
-
187
188
  if not config_file.exists():
188
189
  log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
189
190
  reset_config()
190
- load_user_defined_config()
191
+ return False
192
+ return load_user_defined_config()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.5.22
3
+ Version: 2.5.24
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=hAQqRW-VZgezlnLQtLAB_kXl-vLNgz3ubPhqfDOIrVg,331
2
+ naeural_client/_ver.py,sha256=uGIO8Y2Ti2ygzfAD39SyFQ38eg8DPnoMAKuoyqc1ddo,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=rKOTBmreGwjoEG7CRAAKePNOdl0masfF66ORC-a0vjY,89170
7
+ naeural_client/base/generic_session.py,sha256=Yo65LwSS3R3-ahQlAtXoNsnQHMAEYCFtPGrvYumwgHs,89524
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
@@ -20,9 +20,9 @@ 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
- naeural_client/cli/cli.py,sha256=Yni8USLNK9g9G-l8_XomppZ5tKhduvA8wS4xOw3KODc,3754
23
+ naeural_client/cli/cli.py,sha256=Lo5qsANtjvWP0CG2BxIdYF8QLSpUQoLmYIgCGCVZp9Y,3808
24
24
  naeural_client/cli/cli_commands.py,sha256=Y81oKz5Rx8qxYgzEzCwI9eB8iVL6iET7dETLVygs_VE,1686
25
- naeural_client/cli/nodes.py,sha256=aCbSDFhTnub18LdrOPzu3kvx6acaBqHRgmyAdgqblP8,2459
25
+ naeural_client/cli/nodes.py,sha256=lC6M2ODPyt_ciGIAqz0IJOm9s5PpGWy-gpFdRYlvNuI,3248
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
@@ -30,14 +30,14 @@ naeural_client/comm/__init__.py,sha256=za3B2HUKNXzYtjElMgGM9xbxNsdQfFY4JB_YzdyFk
30
30
  naeural_client/comm/amqp_wrapper.py,sha256=hzj6ih07DnLQy2VSfA88giDIFHaCp9uSdGLTA-IFE4s,8535
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
- naeural_client/const/__init__.py,sha256=OtrSiHyTzrie5dyC1gWrYXYmg5cVMdwe0gxAlrHXCLg,466
33
+ naeural_client/const/__init__.py,sha256=MM6Zib6i7M2qWcMkLtLx14zqU-lE-u2uPHjNvbh2jAM,478
34
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
- naeural_client/const/misc.py,sha256=Y6x00YDtY1_nAk4OvikCLlfp8ggn11WQYTBGYzFlJPk,211
40
+ naeural_client/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
41
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
@@ -79,10 +79,10 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
79
79
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
80
80
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
81
81
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
82
- naeural_client/utils/config.py,sha256=mFqzz69UQAZN9oblxoTqWS52F2p8AnXmzDtdf2SoDz4,5258
82
+ naeural_client/utils/config.py,sha256=m1O6D7jE_vVpWM7kd2ZEs9JOKlM9yMDy5YDcf8vElWo,5357
83
83
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
84
- naeural_client-2.5.22.dist-info/METADATA,sha256=PGQE3We4_RODRS6YsHEyMspcTRDBZZGLuJUsegEB8Ds,14619
85
- naeural_client-2.5.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
- naeural_client-2.5.22.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
- naeural_client-2.5.22.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
- naeural_client-2.5.22.dist-info/RECORD,,
84
+ naeural_client-2.5.24.dist-info/METADATA,sha256=9a21TM1JGOIB0I-xmF0eOpBtbqVpKdHNogqAIZ-Novs,14619
85
+ naeural_client-2.5.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
86
+ naeural_client-2.5.24.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
87
+ naeural_client-2.5.24.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
88
+ naeural_client-2.5.24.dist-info/RECORD,,