naeural-client 2.3.1__py3-none-any.whl → 2.3.2__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.3.1"
1
+ __VER__ = "2.3.2"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
naeural_client/cli/cli.py CHANGED
@@ -15,34 +15,76 @@ def build_parser():
15
15
  Configured argument parser.
16
16
  """
17
17
  descr = f"nepctl v{version} - CLI for Naeural Edge Protocol SDK package"
18
-
19
-
20
18
  parser = argparse.ArgumentParser(description=descr)
21
19
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
22
20
 
23
- # Iterate over top-level commands
24
21
  for command, subcommands in CLI_COMMANDS.items():
25
22
  command_parser = subparsers.add_parser(command, help=f"{command} commands")
26
- if isinstance(subcommands, dict): # Nested subcommands
23
+
24
+ if isinstance(subcommands, dict) and "func" not in subcommands:
25
+ # Nested subcommands
27
26
  command_subparsers = command_parser.add_subparsers(dest="subcommand")
28
- for subcommand, func in subcommands.items():
27
+ for subcommand, subcmd_info in subcommands.items():
29
28
  subcommand_parser = command_subparsers.add_parser(
30
- subcommand, help=f"{subcommand} command"
29
+ subcommand, help=f"{subcommand} command"
31
30
  )
32
- subcommand_parser.set_defaults(func=func)
31
+ if isinstance(subcmd_info, dict) and "params" in subcmd_info:
32
+ for param, description in subcmd_info["params"].items():
33
+ if param.startswith("--"):
34
+ subcommand_parser.add_argument(
35
+ param, action="store_true", help=description
36
+ )
37
+ else:
38
+ subcommand_parser.add_argument(
39
+ param, help=description
40
+ )
41
+ #end if
42
+ #end for
43
+ #end if
44
+ subcommand_parser.set_defaults(func=subcmd_info["func"])
33
45
  else:
34
- command_parser.set_defaults(func=subcommands)
46
+ # Single-level commands with parameters
47
+ if "params" in subcommands:
48
+ for param, description in subcommands["params"].items():
49
+ if param.startswith("--"):
50
+ command_parser.add_argument(
51
+ param, action="store_true", help=description
52
+ )
53
+ else:
54
+ command_parser.add_argument(
55
+ param, help=description
56
+ )
57
+ #end if
58
+ command_parser.set_defaults(func=subcommands["func"])
35
59
 
36
60
  return parser
37
61
 
62
+
63
+
38
64
  def main():
39
- maybe_init_config()
40
- parser = build_parser()
41
- args = parser.parse_args()
42
- if hasattr(args, "func"):
43
- args.func() # Call the dynamically loaded function
44
- else:
45
- parser.print_help()
65
+ """
66
+ Main entry point for the CLI.
67
+ Ensures the configuration is initialized, builds the parser,
68
+ and executes the appropriate command function.
69
+ """
70
+ try:
71
+ # Initialize configuration if necessary
72
+ maybe_init_config()
73
+
74
+ # Build the CLI parser
75
+ parser = build_parser()
76
+ args = parser.parse_args()
77
+
78
+ # Check if a command function is provided
79
+ if hasattr(args, "func"):
80
+ args.func(args) # Pass parsed arguments to the command function
81
+ else:
82
+ parser.print_help()
83
+
84
+ except Exception as e:
85
+ # Handle unexpected errors gracefully
86
+ print(f"Error: {e}")
87
+
46
88
 
47
89
  if __name__ == "__main__":
48
90
  main()
@@ -1,15 +1,42 @@
1
- from naeural_client.cli.nodes import get_nodes, get_supervisors
1
+ from naeural_client.cli.nodes import (
2
+ get_nodes, get_supervisors,
3
+ restart_node, shutdown_node
4
+ )
2
5
  from naeural_client.utils.config import show_config, reset_config
3
6
 
4
7
 
5
8
  # Define the available commands
6
9
  CLI_COMMANDS = {
7
10
  "get": {
8
- "nodes": get_nodes,
9
- "supervisors": get_supervisors,
11
+ "nodes": {
12
+ "func": get_nodes,
13
+ "params": {
14
+ "--all": "Get all nodes",
15
+ "--peered": "Get only peered nodes"
16
+ }
17
+ },
18
+ "supervisors": {
19
+ "func": get_supervisors,
20
+ },
10
21
  },
11
22
  "config": {
12
- "show": show_config,
13
- "reset": reset_config,
23
+ "show": {
24
+ "func": show_config,
25
+ },
26
+ "reset": {
27
+ "func": reset_config,
28
+ },
14
29
  },
15
- }
30
+ "restart": {
31
+ "func": restart_node,
32
+ "params": {
33
+ "node": "The node to restart"
34
+ }
35
+ },
36
+ "shutdown": {
37
+ "func": shutdown_node,
38
+ "params": {
39
+ "node": "The node to shutdown"
40
+ }
41
+ }
42
+ }
@@ -1,7 +1,7 @@
1
1
  from naeural_client.utils.config import log_with_color
2
2
 
3
3
 
4
- def get_nodes():
4
+ def get_nodes(args):
5
5
  """
6
6
  This function is used to get the information about the nodes and it will perform the following:
7
7
 
@@ -10,13 +10,44 @@ def get_nodes():
10
10
  3. Wait for the second net mon message via Session and show progress.
11
11
  4. Get the active nodes union via Session and display the nodes marking those peered vs non-peered.
12
12
  """
13
- log_with_color("Getting nodes information", color="b")
13
+ if args.all:
14
+ log_with_color("Getting all nodes information", color="b")
15
+ elif args.peered:
16
+ log_with_color("Getting peered nodes information", color="b")
17
+ else:
18
+ log_with_color("Getting default nodes information", color="b")
14
19
  return
15
20
 
16
21
 
17
- def get_supervisors():
22
+ def get_supervisors(args):
18
23
  """
19
24
  This function is used to get the information about the supervisors.
20
25
  """
21
26
  log_with_color("Getting supervisors information", color='b')
27
+ return
28
+
29
+
30
+ def restart_node(args):
31
+ """
32
+ This function is used to restart the node.
33
+
34
+ Parameters
35
+ ----------
36
+ args : argparse.Namespace
37
+ Arguments passed to the function.
38
+ """
39
+ log_with_color(f"Restarting node {args.node}", color='b')
40
+ return
41
+
42
+
43
+ def shutdown_node(args):
44
+ """
45
+ This function is used to shutdown the node.
46
+
47
+ Parameters
48
+ ----------
49
+ args : argparse.Namespace
50
+ Arguments passed to the function.
51
+ """
52
+ log_with_color(f"Shutting down node {args.node}", color='b')
22
53
  return
@@ -4,7 +4,7 @@ class COLORS:
4
4
  TIMERS = 'd'
5
5
  STATUS = 'n'
6
6
  SERVING = 'm'
7
- BIZ = 'b'
7
+ BIZ = 'c'
8
8
  COMM = 'y'
9
9
  TIMERS = 'd'
10
10
 
@@ -35,6 +35,8 @@ COLORS = {
35
35
  'y': "\x1b[1;33m",
36
36
  'b': "\x1b[1;34m",
37
37
  'm': "\x1b[1;35m",
38
+ 'c': "\x1b[1;36m", # bright cyan
39
+ 'v': "\x1b[0;36m", # dim cyan
38
40
  'a': "\x1b[41m",
39
41
  'e': "\x1b[41m",
40
42
  'w': "\x1b[1;31m", # warning == red
@@ -31,8 +31,9 @@ def log_with_color(s, color='n'):
31
31
  'r': '\033[31m', # Red
32
32
  'g': '\033[32m', # Green
33
33
  'y': '\033[33m', # Yellow
34
- 'b': '\033[34m', # Blue
34
+ 'b': "\x1b[1;34m", # bright blue
35
35
  'w': '\033[97m', # Light white
36
+ 'c': "\x1b[1;36m", # bright cyan
36
37
  'n': '\033[37m', # Dark white (default)
37
38
  }
38
39
 
@@ -53,7 +54,7 @@ def get_user_config_file():
53
54
  """
54
55
  return get_user_folder() / "config"
55
56
 
56
- def reset_config():
57
+ def reset_config(args):
57
58
  """
58
59
  Resets the configuration by creating a ~/.naeural folder and populating
59
60
  ~/.naeural/config with values from a local .env file, if it exists.
@@ -78,7 +79,7 @@ def reset_config():
78
79
  log_with_color(f"Configuration has been reset to default in {config_file}:\n{ENV_TEMPLATE}", color='y')
79
80
 
80
81
 
81
- def show_config():
82
+ def show_config(args):
82
83
  """
83
84
  Displays the current configuration from ~/.naeural/config.
84
85
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: naeural_client
3
- Version: 2.3.1
3
+ Version: 2.3.2
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,5 +1,5 @@
1
1
  naeural_client/__init__.py,sha256=UKEDGS0wFYyxwmhEAKJGecO2vYbIfRYUP4SQgnK10IE,578
2
- naeural_client/_ver.py,sha256=31pw4Zp2s9RPTWeYsyGqbi2Dc3lW0dqZ4WsTZckfaww,330
2
+ naeural_client/_ver.py,sha256=CQFz97cZD3BHPUwaDADidkQTqRJjpmc10HSuppTZLKA,330
3
3
  naeural_client/base_decentra_object.py,sha256=wXjl65gWxxkhV6Tq48wFfNGITvdYdkKPT-wLurGB5vc,4287
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
@@ -19,9 +19,9 @@ naeural_client/bc/ec.py,sha256=raIGI7BpSH8xU_Bg7RpKv9KEW3F6PuAdL5miZfvw7iI,14027
19
19
  naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1gPULtJNSYUpG_YFkYaMKU,1337
21
21
  naeural_client/cli/README.md,sha256=WPdI_EjzAbUW1aPyj1sSR8rLydcJKZtoiaEtklQrjHo,74
22
- naeural_client/cli/cli.py,sha256=eKzO8hu_436e3svGPNSpn6q4EiEcaTIKPhgn5QOJJVw,1426
23
- naeural_client/cli/cli_commands.py,sha256=NluWqnsyuabu0EKNM6MDUBtnfloH7oqCOrkfJs8Ajjk,353
24
- naeural_client/cli/nodes.py,sha256=y3yKKLzyZe-zu4H-cgqDqmZ8jt1s4RA6QdqeUD7z4i0,713
22
+ naeural_client/cli/cli.py,sha256=puxQ_5acL6tD2YOt8PdO5idiuKT2VUt7YzMigO3IY50,2752
23
+ naeural_client/cli/cli_commands.py,sha256=Sm7_Ig3jxs0P7S9X_vsTrv4jthWfzo9Meb05ufI4pxQ,911
24
+ naeural_client/cli/nodes.py,sha256=0aS9d26DtzEJHcNHiprBxlPPOdEX7B1DXDFyzL9mXVU,1406
25
25
  naeural_client/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
26
26
  naeural_client/code_cheker/base.py,sha256=lT5DRIFO5rqzsMNCmdMRfkAeevmezozehyfgmhnKpuI,19074
27
27
  naeural_client/code_cheker/checker.py,sha256=QWupeM7ToancVIq1tRUxRNUrI8B5l5eoY0kDU4-O5aE,7365
@@ -36,7 +36,7 @@ naeural_client/const/comms.py,sha256=La6JXWHexH8CfcBCKyT4fCIoeaoZlcm7KtZ57ab4ZgU
36
36
  naeural_client/const/environment.py,sha256=iytmTDgbOjvORPwHQmc0K0r-xJx7dnnzNnqAJJiFCDA,870
37
37
  naeural_client/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
38
38
  naeural_client/const/heartbeat.py,sha256=jGHmKfeHTFOXJaKUT3o_ocnQyF-EpcLeunW-ifkYKfU,2534
39
- naeural_client/const/misc.py,sha256=1ypROmZsOyp_8zG2LARwPeo-YfXuyYqZnml0elTP4kw,211
39
+ naeural_client/const/misc.py,sha256=Y6x00YDtY1_nAk4OvikCLlfp8ggn11WQYTBGYzFlJPk,211
40
40
  naeural_client/const/payload.py,sha256=jBzXQZ-jQ1Ft6eRsb8WvT-OPpQd1j4Y-uu_V26-EY0Y,5763
41
41
  naeural_client/default/__init__.py,sha256=ozU6CMMuWl0LhG8Ae3LrZ65a6tLrptfscVYGf83zjxM,46
42
42
  naeural_client/default/instance/__init__.py,sha256=Itb4l6_DR6CCw8KAxyQKlCmALyzDasNHIfM9VB-Umak,548
@@ -56,7 +56,7 @@ naeural_client/io_formatter/default/a_dummy.py,sha256=qr9eUizQ-NN5jdXVzkaZKMaf9K
56
56
  naeural_client/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz5lgrQWo7td5Ri1A,3052
57
57
  naeural_client/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
58
58
  naeural_client/logging/__init__.py,sha256=b79X45VC6c37u32flKB2GAK9f-RR0ocwP0JDCy0t7QQ,33
59
- naeural_client/logging/base_logger.py,sha256=IEhDnR6vn_nMBE4OwzUHO_71wuvAtCXjHHx4yeRxm6s,65880
59
+ naeural_client/logging/base_logger.py,sha256=uyR4rxXQGd9UrdIdRRhS6T7UmnzyEfFooVXikxOsfw4,65951
60
60
  naeural_client/logging/small_logger.py,sha256=m12hCb_H4XifJYYfgCAOUDkcXm-h4pSODnFf277OFVI,2937
61
61
  naeural_client/logging/logger_mixins/__init__.py,sha256=yQO7umlRvz63FeWpi-F9GRmC_MOHcNW6R6pwvZZBy3A,600
62
62
  naeural_client/logging/logger_mixins/class_instance_mixin.py,sha256=xUXE2VZgmrlrSrvw0f6GF1jlTnVLeVkIiG0bhlBfq3o,2741
@@ -78,10 +78,10 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
78
78
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
79
79
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
80
80
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
81
- naeural_client/utils/config.py,sha256=0IngDOJjtopdi06VdtKPRv6qCBOTEt_Ww4l4MIBKhZw,3624
81
+ naeural_client/utils/config.py,sha256=t_VzyBnRHJa-Kt71HUu9gXxeDOri1Aqf_-gjO04gAYs,3681
82
82
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
83
- naeural_client-2.3.1.dist-info/METADATA,sha256=qrRjlmz_8n-D5mCQuYYArpPEzcmQ8CY4b0RkUT_VuIM,14449
84
- naeural_client-2.3.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
85
- naeural_client-2.3.1.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
86
- naeural_client-2.3.1.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
87
- naeural_client-2.3.1.dist-info/RECORD,,
83
+ naeural_client-2.3.2.dist-info/METADATA,sha256=Nt9IRuxQmbjZt3OgMZdbyqXIwo5FDx6rIyzYNsu0czU,14449
84
+ naeural_client-2.3.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
85
+ naeural_client-2.3.2.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
86
+ naeural_client-2.3.2.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
87
+ naeural_client-2.3.2.dist-info/RECORD,,