naeural-client 2.5.21__tar.gz → 2.5.23__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. {naeural_client-2.5.21 → naeural_client-2.5.23}/PKG-INFO +8 -1
  2. {naeural_client-2.5.21 → naeural_client-2.5.23}/README.md +7 -0
  3. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/_ver.py +1 -1
  4. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/generic_session.py +16 -11
  5. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/bc/base.py +8 -6
  6. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/cli/cli.py +12 -11
  7. naeural_client-2.5.23/naeural_client/cli/nodes.py +103 -0
  8. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/__init__.py +1 -1
  9. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/misc.py +10 -0
  10. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/utils/config.py +3 -2
  11. {naeural_client-2.5.21 → naeural_client-2.5.23}/pyproject.toml +1 -1
  12. naeural_client-2.5.23/xperimental/multi-enc-dec/multi_test2.py +44 -0
  13. naeural_client-2.5.21/naeural_client/cli/nodes.py +0 -76
  14. {naeural_client-2.5.21 → naeural_client-2.5.23}/.devcontainer/Dockerfile +0 -0
  15. {naeural_client-2.5.21 → naeural_client-2.5.23}/.devcontainer/devcontainer.json +0 -0
  16. {naeural_client-2.5.21 → naeural_client-2.5.23}/.gitattributes +0 -0
  17. {naeural_client-2.5.21 → naeural_client-2.5.23}/.github/workflows/python-publish.yml +0 -0
  18. {naeural_client-2.5.21 → naeural_client-2.5.23}/.gitignore +0 -0
  19. {naeural_client-2.5.21 → naeural_client-2.5.23}/.vscode/launch.json +0 -0
  20. {naeural_client-2.5.21 → naeural_client-2.5.23}/LICENSE +0 -0
  21. {naeural_client-2.5.21 → naeural_client-2.5.23}/TODOs.md +0 -0
  22. {naeural_client-2.5.21 → naeural_client-2.5.23}/__init__.py +0 -0
  23. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/__init__.py +0 -0
  24. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/__init__.py +0 -0
  25. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/distributed_custom_code_presets.py +0 -0
  26. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/instance.py +0 -0
  27. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/payload/__init__.py +0 -0
  28. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/payload/payload.py +0 -0
  29. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/pipeline.py +0 -0
  30. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/plugin_template.py +0 -0
  31. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/responses.py +0 -0
  32. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/transaction.py +0 -0
  33. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base/webapp_pipeline.py +0 -0
  34. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/base_decentra_object.py +0 -0
  35. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/bc/__init__.py +0 -0
  36. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/bc/chain.py +0 -0
  37. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/bc/ec.py +0 -0
  38. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/certs/__init__.py +0 -0
  39. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt +0 -0
  40. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/cli/README.md +0 -0
  41. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/cli/cli_commands.py +0 -0
  42. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/code_cheker/__init__.py +0 -0
  43. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/code_cheker/base.py +0 -0
  44. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/code_cheker/checker.py +0 -0
  45. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/comm/__init__.py +0 -0
  46. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/comm/amqp_wrapper.py +0 -0
  47. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/comm/mqtt_wrapper.py +0 -0
  48. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/README.md +0 -0
  49. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/apps.py +0 -0
  50. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/base.py +0 -0
  51. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/comms.py +0 -0
  52. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/environment.py +0 -0
  53. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/formatter.py +0 -0
  54. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/heartbeat.py +0 -0
  55. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/const/payload.py +0 -0
  56. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/__init__.py +0 -0
  57. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/__init__.py +0 -0
  58. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/chain_dist_custom_job_01_plugin.py +0 -0
  59. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/custom_webapi_01_plugin.py +0 -0
  60. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/net_mon_01_plugin.py +0 -0
  61. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/telegram_basic_bot_01_plugin.py +0 -0
  62. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/telegram_conversational_bot_01_plugin.py +0 -0
  63. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/instance/view_scene_01_plugin.py +0 -0
  64. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/default/session/mqtt_session.py +0 -0
  65. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/__init__.py +0 -0
  66. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/base/__init__.py +0 -0
  67. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/base/base_formatter.py +0 -0
  68. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/default/__init__.py +0 -0
  69. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/default/a_dummy.py +0 -0
  70. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/default/aixp1.py +0 -0
  71. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/default/default.py +0 -0
  72. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/io_formatter/io_formatter_manager.py +0 -0
  73. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/__init__.py +0 -0
  74. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/base_logger.py +0 -0
  75. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/__init__.py +0 -0
  76. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/class_instance_mixin.py +0 -0
  77. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/computer_vision_mixin.py +0 -0
  78. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/datetime_mixin.py +0 -0
  79. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/download_mixin.py +0 -0
  80. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/general_serialization_mixin.py +0 -0
  81. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/json_serialization_mixin.py +0 -0
  82. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/pickle_serialization_mixin.py +0 -0
  83. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/process_mixin.py +0 -0
  84. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/resource_size_mixin.py +0 -0
  85. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/timers_mixin.py +0 -0
  86. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/upload_mixin.py +0 -0
  87. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/logger_mixins/utils_mixin.py +0 -0
  88. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/small_logger.py +0 -0
  89. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/tzlocal/__init__.py +0 -0
  90. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/tzlocal/unix.py +0 -0
  91. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/tzlocal/utils.py +0 -0
  92. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/tzlocal/win32.py +0 -0
  93. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/logging/tzlocal/windows_tz.py +0 -0
  94. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/plugins_manager_mixin.py +0 -0
  95. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/utils/__init__.py +0 -0
  96. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/utils/comm_utils.py +0 -0
  97. {naeural_client-2.5.21 → naeural_client-2.5.23}/naeural_client/utils/dotenv.py +0 -0
  98. {naeural_client-2.5.21 → naeural_client-2.5.23}/nepctl.MD +0 -0
  99. {naeural_client-2.5.21 → naeural_client-2.5.23}/requirements.txt +0 -0
  100. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/.example_env +0 -0
  101. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/8. custom_code_fastapi_assets/index.html +0 -0
  102. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/9. code_sandbox_from_scratch_assets/index.html +0 -0
  103. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/_example_pk_sdk.pem +0 -0
  104. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex01_part1_connect.py +0 -0
  105. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex01_part2_filter.py +0 -0
  106. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex01_part3_adv_filter.py +0 -0
  107. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex02_first_deploy.py +0 -0
  108. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex03_custom_code_on_one_remote__example_1.py +0 -0
  109. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex04_custom_code_on_one_remote__example_2.py +0 -0
  110. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex05_custom_code_on_one_remote__example_3.py +0 -0
  111. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex06_custom_code_on_multiple_remotes__example_1.py +0 -0
  112. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex07_custom_code_on_multiple_remotes__example_2.py +0 -0
  113. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex08_custom_webapi.py +0 -0
  114. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex09_code_sandbox_from_scratch.py +0 -0
  115. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex10_telegram_echo_bot.py +0 -0
  116. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex11_telegram_blackjack_bot.py +0 -0
  117. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex12_telegram_smart_bot.py +0 -0
  118. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/ex13_launch_repo_based_webapp.py +0 -0
  119. {naeural_client-2.5.21 → naeural_client-2.5.23}/tutorials/video_presentation/1. hello_world.ipynb +0 -0
  120. {naeural_client-2.5.21 → naeural_client-2.5.23}/winrun.bat +0 -0
  121. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/.example_env +0 -0
  122. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/_archive/test.py +0 -0
  123. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/_tutorials/3. simple_real_time_custom_code.py +0 -0
  124. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/_tutorials/4. real_time_custom_code_2.py +0 -0
  125. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/_tutorials/8. chatbot.py +0 -0
  126. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/decentralized/chain_dist_example.py +0 -0
  127. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/decentralized/chain_dist_example_initiator.py +0 -0
  128. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/decentralized/chain_dist_example_worker.py +0 -0
  129. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/enc_dec/enc_dec_test.py +0 -0
  130. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/eth/eth_sign.py +0 -0
  131. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/eth/info.md +0 -0
  132. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/eth/sign.py +0 -0
  133. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/multi-enc-dec/multi_test1.py +0 -0
  134. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/sign/test_sign1.py +0 -0
  135. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/utils/get_documentation.py +0 -0
  136. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/README.md +0 -0
  137. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/attach_example.py +0 -0
  138. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/ex1.py +0 -0
  139. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/hello.py +0 -0
  140. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/remote_exec.py +0 -0
  141. {naeural_client-2.5.21 → naeural_client-2.5.23}/xperimental/various/save_images.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.5.21
3
+ Version: 2.5.23
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
@@ -35,6 +35,13 @@ This packet depends on the following packets: `pika`, `paho-mqtt`, `numpy`, `pyo
35
35
  python -m pip install naeural_client
36
36
  ```
37
37
 
38
+ ### Development installation
39
+
40
+ ```shell
41
+ git clone https://github.com/NaeuralEdgeProtocol/naeural_client
42
+ pip install -e .
43
+ ```
44
+
38
45
  ## Documentation
39
46
 
40
47
  Minimal documentation will be presented here. The complete documentation is
@@ -12,6 +12,13 @@ This packet depends on the following packets: `pika`, `paho-mqtt`, `numpy`, `pyo
12
12
  python -m pip install naeural_client
13
13
  ```
14
14
 
15
+ ### Development installation
16
+
17
+ ```shell
18
+ git clone https://github.com/NaeuralEdgeProtocol/naeural_client
19
+ pip install -e .
20
+ ```
21
+
15
22
  ## Documentation
16
23
 
17
24
  Minimal documentation will be presented here. The complete documentation is
@@ -1,4 +1,4 @@
1
- __VER__ = "2.5.21"
1
+ __VER__ = "2.5.23"
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
@@ -254,10 +254,14 @@ class GenericSession(BaseDecentrAIObject):
254
254
  self.P(msg, color='y')
255
255
  self._connect()
256
256
 
257
- self.P("Created {} comms session '{}' from <{}> SDKv{}.".format(
258
- "decrypted" if not self.encrypt_comms else "encrypted",
259
- self.name, self.bc_engine.address, self.log.version
260
- ))
257
+ msg = f"Created comms session '{self.name}'"
258
+ msg += f"\n - SDK: {self.log.version}"
259
+ msg += f"\n - Address: {self.bc_engine.address}"
260
+ msg += f"\n - Server: {self._config[comm_ct.HOST]}:{self._config[comm_ct.PORT]}"
261
+ msg += f"\n - Secured: {self._config[comm_ct.SECURED]}"
262
+ msg += f"\n - User: {self._config[comm_ct.USER]}"
263
+ msg += f"\n - Encrypt: {'YES' if self.encrypt_comms else 'NO'}"
264
+ self.P(msg, color='g')
261
265
 
262
266
  if not self.encrypt_comms:
263
267
  self.P(
@@ -2320,10 +2324,11 @@ class GenericSession(BaseDecentrAIObject):
2320
2324
  elapsed = tm() - start
2321
2325
  # end while
2322
2326
  # done waiting for supervisors
2327
+ best_super = 'ERROR'
2328
+ best_super_alias = 'ERROR'
2323
2329
 
2324
2330
  if len(self.__current_network_statuses) > 0:
2325
2331
  best_info = {}
2326
- best_super = None
2327
2332
  for supervisor, net_info in self.__current_network_statuses.items():
2328
2333
  if len(net_info) > len(best_info):
2329
2334
  best_info = net_info
@@ -2364,10 +2369,10 @@ class GenericSession(BaseDecentrAIObject):
2364
2369
  # end if
2365
2370
  pd.options.display.float_format = '{:.1f}'.format
2366
2371
  dct_result = _DotDict({
2367
- 'report' : pd.DataFrame(res),
2368
- 'reporter' : best_super,
2369
- 'reporter_alias' : best_super_alias,
2370
- 'nr_super' : len(self.__current_network_statuses),
2371
- 'elapsed' : elapsed,
2372
+ SESSION_CT.NETSTATS_REPORT : pd.DataFrame(res),
2373
+ SESSION_CT.NETSTATS_REPORTER : best_super,
2374
+ SESSION_CT.NETSTATS_REPORTER_ALIAS : best_super_alias,
2375
+ SESSION_CT.NETSTATS_NR_SUPERVISORS : len(self.__current_network_statuses),
2376
+ SESSION_CT.NETSTATS_ELAPSED : elapsed,
2372
2377
  })
2373
2378
  return dct_result
@@ -359,7 +359,7 @@ class BaseBlockEngine:
359
359
  s = "<BC:{}> ".format(self.__name) + s
360
360
  return self.log.P(
361
361
  s,
362
- color='g' if (color is None or color.lower() not in ['r', 'red', 'error']) else color,
362
+ color=color or 'd',
363
363
  boxed=boxed,
364
364
  **kwargs
365
365
  )
@@ -375,8 +375,7 @@ class BaseBlockEngine:
375
375
 
376
376
  def _init(self):
377
377
  self.P(
378
- f"Initializing BC-engine (ETH_ENABLED={self.__eth_enabled})...",
379
- boxed=True, box_char='*', verbosity=1
378
+ f"Initializing BC-engine (ETH_ENABLED={self.__eth_enabled})...", verbosity=1
380
379
  )
381
380
 
382
381
  if True:
@@ -414,9 +413,12 @@ class BaseBlockEngine:
414
413
  self.__eth_account = self._get_eth_account()
415
414
  ### end Ethereum
416
415
  if self.__eth_enabled:
417
- self.P("Address: {} / ETH: {}".format(self.address, self.eth_address), boxed=True, verbosity=1)
416
+ self.P(
417
+ "Address: {} / ETH: {}".format(self.address, self.eth_address), boxed=True, verbosity=1,
418
+ color='g'
419
+ )
418
420
  else:
419
- self.P("Address: {}".format(self.address), boxed=True, verbosity=1)
421
+ self.P("Address: {}".format(self.address), boxed=True, color='g', verbosity=1)
420
422
  self.P("Allowed list of senders: {}".format(self.allowed_list), verbosity=1)
421
423
  return
422
424
 
@@ -702,7 +704,7 @@ class BaseBlockEngine:
702
704
 
703
705
  """
704
706
  if from_file and os.path.isfile(source):
705
- self.P("Reading SK from '{}'".format(source), color='g', verbosity=1)
707
+ self.P("Reading SK from '{}'".format(source), verbosity=1)
706
708
  with open(source, 'rt') as fh:
707
709
  data = fh.read()
708
710
  else:
@@ -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
@@ -0,0 +1,103 @@
1
+ from time import time
2
+ from naeural_client.utils.config import log_with_color
3
+ from naeural_client.const import SESSION_CT
4
+
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
+
28
+ def get_nodes(args):
29
+ """
30
+ This function is used to get the information about the nodes and it will perform the following:
31
+
32
+ 1. Create a Session object.
33
+ 2. Wait for the first net mon message via Session and show progress.
34
+ 3. Wait for the second net mon message via Session and show progress.
35
+ 4. Get the active nodes union via Session and display the nodes marking those peered vs non-peered.
36
+ """
37
+ supervisor_addr = args.supervisor
38
+ if args.verbose:
39
+ log_with_color(f"Getting nodes from supervisor <{supervisor_addr}>...", color='b')
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,
46
+ )
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}")
55
+ return
56
+
57
+
58
+ def get_supervisors(args):
59
+ """
60
+ This function is used to get the information about the supervisors.
61
+ """
62
+ if args.verbose:
63
+ log_with_color("Getting supervisors...", color='b')
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}")
77
+ return
78
+
79
+
80
+ def restart_node(args):
81
+ """
82
+ This function is used to restart the node.
83
+
84
+ Parameters
85
+ ----------
86
+ args : argparse.Namespace
87
+ Arguments passed to the function.
88
+ """
89
+ log_with_color(f"Restarting node {args.node} NOT IMPLEMENTED", color='r')
90
+ return
91
+
92
+
93
+ def shutdown_node(args):
94
+ """
95
+ This function is used to shutdown the node.
96
+
97
+ Parameters
98
+ ----------
99
+ args : argparse.Namespace
100
+ Arguments passed to the function.
101
+ """
102
+ log_with_color(f"Shutting down node {args.node} NOT IMPLEMENTED", color='r')
103
+ return
@@ -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
+
@@ -83,11 +83,12 @@ def get_user_config_file():
83
83
  """
84
84
  return get_user_folder() / "config"
85
85
 
86
- def reset_config(args, *larg, **kwargs):
86
+ def reset_config(*larg, **kwargs):
87
87
  """
88
88
  Resets the configuration by creating a ~/.naeural folder and populating
89
89
  ~/.naeural/config with values from a local .env file, if it exists.
90
90
  """
91
+ log_with_color("Resetting the configuration...", color='y')
91
92
  # Define the target config folder and file
92
93
  config_dir = get_user_folder()
93
94
  config_file = get_user_config_file()
@@ -186,4 +187,4 @@ def maybe_init_config():
186
187
  if not config_file.exists():
187
188
  log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
188
189
  reset_config()
189
- load_user_defined_config()
190
+ return load_user_defined_config()
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "naeural_client"
7
- version = "2.5.21"
7
+ version = "2.5.23"
8
8
  authors = [
9
9
  { name="Andrei Ionut Damian", email="andrei.damian@me.com" },
10
10
  { name="Cristan Bleotiu", email="cristibleotiu@gmail.com" },
@@ -0,0 +1,44 @@
1
+ import json
2
+
3
+ from naeural_client import Logger, const
4
+ from naeural_client.bc import DefaultBlockEngine
5
+
6
+
7
+
8
+ if __name__ == '__main__' :
9
+ l = Logger("ENC", base_folder=".", app_folder="_local_cache")
10
+
11
+
12
+ data = {
13
+ "EE_IS_ENCRYPTED": True,
14
+ "EE_ENCRYPTED_DATA": "fwcctxETcji64z/KAYFmyWE8RDrJwm2BToMMZD9uesGtWatmDA1nadqpaAwlQajJg9SYb6jeadwxeIqg15VlDmNO9X2dxSiu151Dos900kx2Y8dM3q/S7A==",
15
+ "EE_ID": "0xai_A9gulGoLPxo7hOo05GIeSvfld_IF_CucTnP00CznjmJN",
16
+ "SESSION_ID": "SolisClient_bf2d",
17
+ "INITIATOR_ID": "SolisClient_bf2d",
18
+ "EE_SENDER": "0xai_Ag28FO6Yg254w-RHsBtODc_WLq7jz4SwfUAW7S7zP0U1",
19
+ "TIME": "2025-01-07 00:37:16.291005",
20
+ "EE_SIGN": "MEQCIH9T4_zB4v8cgjhUAwOvELrthGCUZ4v87LR-5DnFetkuAiAm2nOoZIitma10skQbuf12Yp9l_M7zyAcG9mWScuPZGw==",
21
+ "EE_HASH": "7d7d49f39d1f870af74bece27262d9b050b5358a15c71b249150d04a712ce72c"
22
+ }
23
+
24
+
25
+ eng1 = DefaultBlockEngine(
26
+ log=l, name="test1",
27
+ config={
28
+ "PEM_FILE" : "stg-0.pem",
29
+ "PASSWORD" : None,
30
+ "PEM_LOCATION" : "data"
31
+ }
32
+ )
33
+
34
+
35
+ ver = eng1.verify(data)
36
+
37
+ eng1.P(f"Signature: {'OK' if ver.valid else 'ERROR'}, {ver}", color='g' if ver.valid else 'r')
38
+
39
+ decr = eng1.decrypt(
40
+ encrypted_data_b64=data["EE_ENCRYPTED_DATA"],
41
+ sender_address=data["EE_SENDER"],
42
+ debug=True,
43
+ )
44
+ eng1.P(f"Decrypted: {decr}")
@@ -1,76 +0,0 @@
1
- from naeural_client.utils.config import log_with_color
2
-
3
-
4
- def get_nodes(args):
5
- """
6
- This function is used to get the information about the nodes and it will perform the following:
7
-
8
- 1. Create a Session object.
9
- 2. Wait for the first net mon message via Session and show progress.
10
- 3. Wait for the second net mon message via Session and show progress.
11
- 4. Get the active nodes union via Session and display the nodes marking those peered vs non-peered.
12
- """
13
- supervisor_addr = args.supervisor
14
- if args.verbose:
15
- 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
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}")
32
- return
33
-
34
-
35
- def get_supervisors(args):
36
- """
37
- This function is used to get the information about the supervisors.
38
- """
39
- if args.verbose:
40
- 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}")
50
- return
51
-
52
-
53
- def restart_node(args):
54
- """
55
- This function is used to restart the node.
56
-
57
- Parameters
58
- ----------
59
- args : argparse.Namespace
60
- Arguments passed to the function.
61
- """
62
- log_with_color(f"Restarting node {args.node} NOT IMPLEMENTED", color='r')
63
- return
64
-
65
-
66
- def shutdown_node(args):
67
- """
68
- This function is used to shutdown the node.
69
-
70
- Parameters
71
- ----------
72
- args : argparse.Namespace
73
- Arguments passed to the function.
74
- """
75
- log_with_color(f"Shutting down node {args.node} NOT IMPLEMENTED", color='r')
76
- return
File without changes