naeural-client 2.7.5__tar.gz → 2.7.7__tar.gz

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.
Files changed (156) hide show
  1. {naeural_client-2.7.5 → naeural_client-2.7.7}/PKG-INFO +1 -1
  2. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/_ver.py +1 -1
  3. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/generic_session.py +82 -39
  4. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/bc/base.py +3 -0
  5. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/environment.py +3 -3
  6. {naeural_client-2.7.5 → naeural_client-2.7.7}/nepctl.MD +1 -1
  7. {naeural_client-2.7.5 → naeural_client-2.7.7}/pyproject.toml +1 -1
  8. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/.example_env +1 -1
  9. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex01_part1_connect.py +16 -3
  10. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex01_part2_filter.py +8 -4
  11. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex01_part3_adv_filter.py +11 -1
  12. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex02_part1_deploy_webapi.py +15 -3
  13. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex02_part2_deploy_plugin.py +14 -4
  14. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex08_custom_webapi.py +1 -1
  15. naeural_client-2.7.7/tutorials/ex10_telegram_echo_bot.py +57 -0
  16. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex11_telegram_blackjack_bot.py +23 -3
  17. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex12_telegram_smart_bot.py +12 -8
  18. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex13_launch_repo_based_webapp.py +2 -2
  19. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/auth_check.py +20 -2
  20. naeural_client-2.7.7/xperimental/_checks/session_check.py +11 -0
  21. naeural_client-2.7.5/tutorials/ex10_telegram_echo_bot.py +0 -45
  22. naeural_client-2.7.5/xperimental/_checks/session_check.py +0 -8
  23. naeural_client-2.7.5/xperimental/test1.py +0 -49
  24. {naeural_client-2.7.5 → naeural_client-2.7.7}/.devcontainer/Dockerfile +0 -0
  25. {naeural_client-2.7.5 → naeural_client-2.7.7}/.devcontainer/devcontainer.json +0 -0
  26. {naeural_client-2.7.5 → naeural_client-2.7.7}/.gitattributes +0 -0
  27. {naeural_client-2.7.5 → naeural_client-2.7.7}/.github/workflows/python-publish.yml +0 -0
  28. {naeural_client-2.7.5 → naeural_client-2.7.7}/.gitignore +0 -0
  29. {naeural_client-2.7.5 → naeural_client-2.7.7}/.vscode/launch.json +0 -0
  30. {naeural_client-2.7.5 → naeural_client-2.7.7}/LICENSE +0 -0
  31. {naeural_client-2.7.5 → naeural_client-2.7.7}/README.md +0 -0
  32. {naeural_client-2.7.5 → naeural_client-2.7.7}/TODOs.md +0 -0
  33. {naeural_client-2.7.5 → naeural_client-2.7.7}/__init__.py +0 -0
  34. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/__init__.py +0 -0
  35. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/__init__.py +0 -0
  36. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/distributed_custom_code_presets.py +0 -0
  37. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/instance.py +0 -0
  38. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/payload/__init__.py +0 -0
  39. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/payload/payload.py +0 -0
  40. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/pipeline.py +0 -0
  41. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/plugin_template.py +0 -0
  42. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/responses.py +0 -0
  43. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/transaction.py +0 -0
  44. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base/webapp_pipeline.py +0 -0
  45. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/base_decentra_object.py +0 -0
  46. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/bc/__init__.py +0 -0
  47. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/bc/chain.py +0 -0
  48. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/bc/ec.py +0 -0
  49. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/certs/__init__.py +0 -0
  50. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt +0 -0
  51. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/certs/s624dbd4.ala.us-east-1.emqxsl.com.crt +0 -0
  52. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/cli/README.md +0 -0
  53. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/cli/cli.py +0 -0
  54. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/cli/cli_commands.py +0 -0
  55. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/cli/nodes.py +0 -0
  56. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/cli/oracles.py +0 -0
  57. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/code_cheker/__init__.py +0 -0
  58. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/code_cheker/base.py +0 -0
  59. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/code_cheker/checker.py +0 -0
  60. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/comm/__init__.py +0 -0
  61. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/comm/amqp_wrapper.py +0 -0
  62. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/comm/mqtt_wrapper.py +0 -0
  63. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/README.md +0 -0
  64. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/__init__.py +0 -0
  65. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/apps.py +0 -0
  66. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/base.py +0 -0
  67. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/comms.py +0 -0
  68. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/formatter.py +0 -0
  69. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/heartbeat.py +0 -0
  70. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/misc.py +0 -0
  71. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/const/payload.py +0 -0
  72. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/__init__.py +0 -0
  73. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/__init__.py +0 -0
  74. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/chain_dist_custom_job_01_plugin.py +0 -0
  75. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/custom_webapi_01_plugin.py +0 -0
  76. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/net_mon_01_plugin.py +0 -0
  77. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/telegram_basic_bot_01_plugin.py +0 -0
  78. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/telegram_conversational_bot_01_plugin.py +0 -0
  79. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/instance/view_scene_01_plugin.py +0 -0
  80. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/default/session/mqtt_session.py +0 -0
  81. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/__init__.py +0 -0
  82. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/base/__init__.py +0 -0
  83. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/base/base_formatter.py +0 -0
  84. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/default/__init__.py +0 -0
  85. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/default/a_dummy.py +0 -0
  86. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/default/aixp1.py +0 -0
  87. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/default/default.py +0 -0
  88. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/io_formatter/io_formatter_manager.py +0 -0
  89. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/__init__.py +0 -0
  90. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/base_logger.py +0 -0
  91. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/__init__.py +0 -0
  92. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/class_instance_mixin.py +0 -0
  93. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/computer_vision_mixin.py +0 -0
  94. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/datetime_mixin.py +0 -0
  95. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/download_mixin.py +0 -0
  96. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/general_serialization_mixin.py +0 -0
  97. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/json_serialization_mixin.py +0 -0
  98. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/pickle_serialization_mixin.py +0 -0
  99. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/process_mixin.py +0 -0
  100. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/resource_size_mixin.py +0 -0
  101. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/timers_mixin.py +0 -0
  102. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/upload_mixin.py +0 -0
  103. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/logger_mixins/utils_mixin.py +0 -0
  104. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/small_logger.py +0 -0
  105. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/tzlocal/__init__.py +0 -0
  106. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/tzlocal/unix.py +0 -0
  107. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/tzlocal/utils.py +0 -0
  108. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/tzlocal/win32.py +0 -0
  109. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/logging/tzlocal/windows_tz.py +0 -0
  110. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/plugins_manager_mixin.py +0 -0
  111. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/utils/__init__.py +0 -0
  112. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/utils/comm_utils.py +0 -0
  113. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/utils/config.py +0 -0
  114. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/utils/dotenv.py +0 -0
  115. {naeural_client-2.7.5 → naeural_client-2.7.7}/naeural_client/utils/oracle_sync/oracle_tester.py +0 -0
  116. {naeural_client-2.7.5 → naeural_client-2.7.7}/requirements.txt +0 -0
  117. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/8. custom_code_fastapi_assets/index.html +0 -0
  118. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/9. code_sandbox_from_scratch_assets/index.html +0 -0
  119. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/_example_pk_sdk.pem +0 -0
  120. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex03_custom_code_on_one_remote__example_1.py +0 -0
  121. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex04_custom_code_on_one_remote__example_2.py +0 -0
  122. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex05_custom_code_on_one_remote__example_3.py +0 -0
  123. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex06_custom_code_on_multiple_remotes__example_1.py +0 -0
  124. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex07_custom_code_on_multiple_remotes__example_2.py +0 -0
  125. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/ex09_code_sandbox_from_scratch.py +0 -0
  126. {naeural_client-2.7.5 → naeural_client-2.7.7}/tutorials/video_presentation/1. hello_world.ipynb +0 -0
  127. {naeural_client-2.7.5 → naeural_client-2.7.7}/winrun.bat +0 -0
  128. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/README.md +0 -0
  129. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/cstore_check.py +0 -0
  130. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/keys_check.py +0 -0
  131. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/ora_check.py +0 -0
  132. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/payload_check.py +0 -0
  133. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/_checks/web3_check.py +0 -0
  134. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/decentralized/chain_dist_example.py +0 -0
  135. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/decentralized/chain_dist_example_initiator.py +0 -0
  136. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/decentralized/chain_dist_example_worker.py +0 -0
  137. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/enc_dec/enc_dec_test.py +0 -0
  138. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/eth/eth_sign.py +0 -0
  139. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/eth/info.md +0 -0
  140. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/eth/sign.py +0 -0
  141. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/multi-enc-dec/multi_test1.py +0 -0
  142. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/multi-enc-dec/multi_test2.py +0 -0
  143. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/sign/simple_payload_checker.py +0 -0
  144. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/sign/test_sign1.py +0 -0
  145. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/sign/test_sign2.py +0 -0
  146. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/utils/get_documentation.py +0 -0
  147. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/various/attach_example.py +0 -0
  148. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/various/ex1.py +0 -0
  149. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/various/hello.py +0 -0
  150. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/various/remote_exec.py +0 -0
  151. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/various/save_images.py +0 -0
  152. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/wl/wl_add.py +0 -0
  153. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/xarchive/_tutorials/3. simple_real_time_custom_code.py +0 -0
  154. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/xarchive/_tutorials/4. real_time_custom_code_2.py +0 -0
  155. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/xarchive/_tutorials/8. chatbot.py +0 -0
  156. {naeural_client-2.7.5 → naeural_client-2.7.7}/xperimental/xarchive/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.7.5
3
+ Version: 2.7.7
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,4 +1,4 @@
1
- __VER__ = "2.7.5"
1
+ __VER__ = "2.7.7"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -42,6 +42,7 @@ from ..utils.config import (
42
42
 
43
43
 
44
44
  DEBUG_MQTT_SERVER = "r9092118.ala.eu-central-1.emqxsl.com"
45
+ SDK_NETCONFIG_REQUEST_DELAY = 300
45
46
 
46
47
 
47
48
  class GenericSession(BaseDecentrAIObject):
@@ -88,6 +89,7 @@ class GenericSession(BaseDecentrAIObject):
88
89
  on_notification=None,
89
90
  on_heartbeat=None,
90
91
  debug_silent=True,
92
+ debug=False,
91
93
  silent=False,
92
94
  verbosity=1,
93
95
  dotenv_path=None,
@@ -156,8 +158,13 @@ class GenericSession(BaseDecentrAIObject):
156
158
  As arguments, it has a reference to this Session object, the node name and the heartbeat payload.
157
159
  Defaults to None.
158
160
 
159
- debug_silent : bool, optional
161
+ debug_silent : bool, optional
160
162
  This flag will disable debug logs, set to 'False` for a more verbose log, by default True
163
+ Observation: Obsolete, will be removed
164
+
165
+ debug : bool, optional
166
+ This flag will enable debug logs, set to 'False` for a more verbose log, by default False
167
+
161
168
 
162
169
  silent : bool, optional
163
170
  This flag will disable all logs, set to 'False` for a more verbose log, by default False
@@ -174,9 +181,11 @@ class GenericSession(BaseDecentrAIObject):
174
181
  Defaults to True.
175
182
  """
176
183
 
184
+ debug = debug or not debug_silent
185
+
177
186
  self.__at_least_one_node_peered = False
178
187
  self.__at_least_a_netmon_received = False
179
-
188
+
180
189
  # TODO: maybe read config from file?
181
190
  self._config = {**self.default_config, **config}
182
191
 
@@ -204,6 +213,9 @@ class GenericSession(BaseDecentrAIObject):
204
213
  self._dct_can_send_to_node: dict[str, bool] = {}
205
214
  self._dct_node_last_seen_time = {} # key is node address
206
215
  self._dct_node_addr_name = {}
216
+
217
+ self._dct_netconfig_pipelines_requests = {}
218
+
207
219
  self.online_timeout = 60
208
220
  self.filter_workers = filter_workers
209
221
  self.__show_commands = show_commands
@@ -260,7 +272,7 @@ class GenericSession(BaseDecentrAIObject):
260
272
 
261
273
  super(GenericSession, self).__init__(
262
274
  log=log,
263
- DEBUG=not debug_silent,
275
+ DEBUG=debug,
264
276
  create_logger=True,
265
277
  silent=self.silent,
266
278
  local_cache_base_folder=local_cache_base_folder,
@@ -528,8 +540,7 @@ class GenericSession(BaseDecentrAIObject):
528
540
  **kwargs
529
541
  )
530
542
  self.bc_engine.sign(msg_to_send)
531
- if not self.silent:
532
- self.P(f'Sending encrypted payload to <{node_addr}>', color='y')
543
+ self.P(f'Sending encrypted payload to <{node_addr}>', color='d')
533
544
  self._send_payload(msg_to_send)
534
545
  return
535
546
 
@@ -551,10 +562,12 @@ class GenericSession(BaseDecentrAIObject):
551
562
  additional_data = {
552
563
  PAYLOAD_DATA.EE_PAYLOAD_PATH: [self.bc_engine.address, DEFAULT_PIPELINES.ADMIN_PIPELINE, PLUGIN_SIGNATURES.NET_CONFIG_MONITOR, None]
553
564
  }
565
+ self.D("Sending net-config request to <{}>".format(node_addr), color='y')
554
566
  self.send_encrypted_payload(
555
567
  node_addr=node_addr, payload=payload,
556
568
  additional_data=additional_data
557
569
  )
570
+ self._dct_netconfig_pipelines_requests[node_addr] = tm()
558
571
  return
559
572
 
560
573
  def __track_allowed_node_by_netmon(self, node_addr, dict_msg):
@@ -578,9 +591,17 @@ class GenericSession(BaseDecentrAIObject):
578
591
  self.__track_online_node(node_addr, node_alias)
579
592
 
580
593
  client_is_allowed = self.bc_engine.contains_current_address(node_whitelist)
581
- can_send = not node_secured or client_is_allowed or self.bc_engine.address == node_addr
594
+ can_send = not node_secured or client_is_allowed or self.bc_engine.address == node_addr
582
595
  if node_addr not in self._dct_can_send_to_node and can_send:
583
- self.__request_pipelines_from_net_config_monitor(node_addr)
596
+ if node_online:
597
+ # only attempt to request pipelines if the node is online and if not recently requested
598
+ last_requested_by_netmon = self._dct_netconfig_pipelines_requests.get(node_addr, 0)
599
+ if tm() - last_requested_by_netmon > SDK_NETCONFIG_REQUEST_DELAY:
600
+ self.__request_pipelines_from_net_config_monitor(node_addr)
601
+ else:
602
+ self.D(f"Node <{node_addr}> is online but pipelines were recently requested", color='y')
603
+ else:
604
+ self.D(f"Node <{node_addr}> is offline thus NOT sending net-config request", color='y')
584
605
  # endif node seen for the first time
585
606
 
586
607
  self._dct_can_send_to_node[node_addr] = can_send
@@ -623,6 +644,7 @@ class GenericSession(BaseDecentrAIObject):
623
644
  The name of the instance that sent the message.
624
645
  """
625
646
  # extract relevant data from the message
647
+ self.D("<HB> Received hb from: {}".format(msg_node_addr), verbosity=2)
626
648
 
627
649
  if dict_msg.get(HB.HEARTBEAT_VERSION) == HB.V2:
628
650
  str_data = self.log.decompress_text(dict_msg[HB.ENCODED_DATA])
@@ -647,7 +669,7 @@ class GenericSession(BaseDecentrAIObject):
647
669
  # this is for legacy and custom implementation where heartbeats still contain
648
670
  # the pipeline configuration.
649
671
  pipeline_names = [x.get(PAYLOAD_DATA.NAME, None) for x in msg_active_configs]
650
- self.D(f'<HB>Received pipelines from <{msg_node_addr}>:{pipeline_names}', color='y')
672
+ self.D(f'<HB> Processing pipelines from <{msg_node_addr}>:{pipeline_names}', color='y')
651
673
  self.__process_node_pipelines(msg_node_addr, msg_active_configs)
652
674
 
653
675
  # TODO: move this call in `__on_message_default_callback`
@@ -661,7 +683,7 @@ class GenericSession(BaseDecentrAIObject):
661
683
  for transaction in open_transactions_copy:
662
684
  transaction.handle_heartbeat(dict_msg)
663
685
 
664
- self.D("Received hb from: {}".format(msg_node_addr), verbosity=2)
686
+ self.D("<HB> Received hb from: {}".format(msg_node_addr), verbosity=2)
665
687
 
666
688
  self.__track_allowed_node_by_hb(msg_node_addr, dict_msg)
667
689
 
@@ -746,27 +768,31 @@ class GenericSession(BaseDecentrAIObject):
746
768
  current_network = dict_msg.get(PAYLOAD_DATA.NETMON_CURRENT_NETWORK, {})
747
769
  if current_network:
748
770
  self.__at_least_a_netmon_received = True
749
- all_addresses = [
750
- x[PAYLOAD_DATA.NETMON_ADDRESS] for x in current_network.values()
751
- ]
752
- online_addresses = [
753
- x[PAYLOAD_DATA.NETMON_ADDRESS] for x in current_network.values()
754
- if x[PAYLOAD_DATA.NETMON_STATUS_KEY] == PAYLOAD_DATA.NETMON_STATUS_ONLINE
755
- ]
756
- self.P(f"Net config from <{sender_addr}> `{ee_id}`: {len(online_addresses)}/{len(all_addresses)}", color='y')
757
771
  self.__current_network_statuses[sender_addr] = current_network
758
-
772
+ online_addresses = []
773
+ all_addresses = []
759
774
  for _ , node_data in current_network.items():
760
- node_addr = node_data.get("address", None)
775
+ node_addr = node_data.get(PAYLOAD_DATA.NETMON_ADDRESS, None)
776
+ all_addresses.append(node_addr)
777
+ is_online = node_data.get(PAYLOAD_DATA.NETMON_STATUS_KEY) == PAYLOAD_DATA.NETMON_STATUS_ONLINE
778
+ node_alias = node_data.get(PAYLOAD_DATA.NETMON_EEID, None)
779
+ if is_online:
780
+ # no need to call here __track_online_node as it is already called
781
+ # in below in __track_allowed_node_by_netmon
782
+ online_addresses.append(node_addr)
783
+ # end if is_online
761
784
  if node_addr is not None:
762
785
  self.__track_allowed_node_by_netmon(node_addr, node_data)
763
- nr_peers = sum([v for k, v in self._dct_can_send_to_node.items()])
764
- if nr_peers > 0 and not self.__at_least_one_node_peered:
765
- self.__at_least_one_node_peered = True
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
- )
786
+ # end if node_addr
787
+ # end for each node in network map
788
+ nr_peers = sum(self._dct_can_send_to_node.values())
789
+ self.P(f"Net config from <{sender_addr}> `{ee_id}`: {len(online_addresses)}/{len(all_addresses)}", color='y')
790
+ if nr_peers > 0 and not self.__at_least_one_node_peered:
791
+ self.__at_least_one_node_peered = True
792
+ self.P(
793
+ 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)}",
794
+ color='g'
795
+ )
770
796
  # end for each node in network map
771
797
  # end if current_network is valid
772
798
  # end if NET_MON_01
@@ -786,31 +812,37 @@ class GenericSession(BaseDecentrAIObject):
786
812
  if msg_pipeline.lower() == REQUIRED_PIPELINE.lower() and msg_signature.upper() == REQUIRED_SIGNATURE.upper():
787
813
  # extract data
788
814
  sender_addr = dict_msg.get(PAYLOAD_DATA.EE_SENDER, None)
815
+ short_sender_addr = sender_addr[:8] + '...' + sender_addr[-4:]
816
+ if self.client_address == sender_addr:
817
+ self.D("<NETCFG> Ignoring message from self", color='d')
789
818
  receiver = dict_msg.get(PAYLOAD_DATA.EE_DESTINATION, None)
790
819
  if not isinstance(receiver, list):
791
820
  receiver = [receiver]
792
821
  path = dict_msg.get(PAYLOAD_DATA.EE_PAYLOAD_PATH, [None, None, None, None])
793
822
  ee_id = dict_msg.get(PAYLOAD_DATA.EE_ID, None)
823
+ op = dict_msg.get(NET_CONFIG.NET_CONFIG_DATA, {}).get(NET_CONFIG.OPERATION, "UNKNOWN")
824
+ # drop any incoming request as we are not a net-config provider just a consumer
825
+ if op == NET_CONFIG.REQUEST_COMMAND:
826
+ self.P(f"<NETCFG> Dropping request from <{short_sender_addr}> `{ee_id}`", color='d')
827
+ return
794
828
 
795
829
  # check if I am allowed to see this payload
796
830
  if not self.bc_engine.contains_current_address(receiver):
797
- self.P(f"Received net-config from <{sender_addr}> `{ee_id}` but I am not in the receiver list: {receiver}", color='d')
831
+ self.P(f"<NETCFG> Received `{op}` from <{short_sender_addr}> `{ee_id}` but I am not in the receiver list: {receiver}", color='d')
798
832
  return
799
833
 
800
- # decrypt payload
834
+ # encryption check. By now all should be decrypted
801
835
  is_encrypted = dict_msg.get(PAYLOAD_DATA.EE_IS_ENCRYPTED, False)
802
836
  if not is_encrypted:
803
- self.P(f"Received net-config from <{sender_addr}> `{ee_id}` but it is not encrypted", color='r')
837
+ self.P(f"<NETCFG> Received from <{short_sender_addr}> `{ee_id}` but it is not encrypted", color='r')
804
838
  return
805
839
  net_config_data = dict_msg.get(NET_CONFIG.NET_CONFIG_DATA, {})
806
840
  received_pipelines = net_config_data.get('PIPELINES', [])
807
- self.D(f"Received {len(received_pipelines)} pipelines from <{sender_addr}>")
841
+ self.D(f"<NETCFG> Received {len(received_pipelines)} pipelines from <{sender_addr}>")
808
842
  new_pipelines = self.__process_node_pipelines(sender_addr, received_pipelines)
809
843
  pipeline_names = [x.name for x in new_pipelines]
810
- self.P(f'<NETCFG>Received pipelines from <{sender_addr}>:{pipeline_names}', color='y')
811
- self.D(f'[DEBUG][NETCFG]Received pipelines from <{sender_addr}>:\n{new_pipelines}', color='y')
812
-
813
- # load with same method as a hb
844
+ if len(new_pipelines) > 0:
845
+ self.P(f'<NETCFG> Received NEW pipelines from <{sender_addr}>:{pipeline_names}', color='y')
814
846
  return True
815
847
 
816
848
 
@@ -1163,7 +1195,8 @@ class GenericSession(BaseDecentrAIObject):
1163
1195
  self,
1164
1196
  seconds=10,
1165
1197
  close_session_on_timeout=True,
1166
- close_pipeline_on_timeout=False
1198
+ close_pipeline_on_timeout=False,
1199
+ **kwargs,
1167
1200
  ):
1168
1201
  """
1169
1202
  Wait for a given amount of time.
@@ -1178,11 +1211,21 @@ class GenericSession(BaseDecentrAIObject):
1178
1211
 
1179
1212
  close_pipeline_on_timeout : bool, optional
1180
1213
  If `True`, will close the pipelines when the time is up, by default False
1214
+
1215
+ **kwargs : dict
1216
+ Additional or replacement parameters to be passed to the `run` method:
1217
+ `close_session` : bool - If `True` will close the session when the loop is exited.
1218
+ `close_pipelines` : bool - If `True` will close all pipelines initiated by this session when the loop is exited.
1219
+
1181
1220
  """
1221
+ if "close_pipelines" in kwargs:
1222
+ close_pipeline_on_timeout = kwargs.get("close_pipelines")
1223
+ if "close_session" in kwargs:
1224
+ close_session_on_timeout = kwargs.get("close_session")
1182
1225
  self.run(
1183
1226
  wait=seconds,
1184
1227
  close_session=close_session_on_timeout,
1185
- close_pipelines=close_pipeline_on_timeout
1228
+ close_pipelines=close_pipeline_on_timeout,
1186
1229
  )
1187
1230
  return
1188
1231
 
@@ -2388,13 +2431,13 @@ class GenericSession(BaseDecentrAIObject):
2388
2431
  if telegram_bot_token is None:
2389
2432
  telegram_bot_token = os.getenv(telegram_bot_token_env_key)
2390
2433
  if telegram_bot_token is None:
2391
- message = f"Warning! No Telegram bot token provided as via env {ENVIRONMENT.TELEGRAM_BOT_TOKEN_ENV_KEY} or explicitly as `telegram_bot_token` param."
2434
+ message = f"Warning! No Telegram bot token provided as via env '{telegram_bot_token_env_key}' or explicitly as `telegram_bot_token` param."
2392
2435
  raise ValueError(message)
2393
2436
 
2394
2437
  if telegram_bot_name is None:
2395
- telegram_bot_name = os.getenv(telegram_bot_name_env_key)
2438
+ telegram_bot_name = os.getenv(telegram_bot_name_env_key, name)
2396
2439
  if telegram_bot_name is None:
2397
- message = f"Warning! No Telegram bot name provided as via env {ENVIRONMENT.TELEGRAM_BOT_NAME_ENV_KEY} or explicitly as `telegram_bot_name` param."
2440
+ message = f"Warning! No Telegram bot name provided as via env '{telegram_bot_name_env_key}' or explicitly as `telegram_bot_name` param."
2398
2441
  raise ValueError(message)
2399
2442
 
2400
2443
 
@@ -1514,6 +1514,7 @@ class BaseBlockEngine:
1514
1514
  debug=False,
1515
1515
  max_tries=5,
1516
1516
  network=None,
1517
+ return_full_data=False,
1517
1518
  **kwargs
1518
1519
  ):
1519
1520
  """
@@ -1662,4 +1663,6 @@ class BaseBlockEngine:
1662
1663
  # Invalid URL, thus dct_env will remain None
1663
1664
  self.P(f"dAuth URL is not invalid: {url}", color='r')
1664
1665
  #end if url is valid
1666
+ if return_full_data:
1667
+ return dct_response
1665
1668
  return dct_env
@@ -29,7 +29,7 @@ class ENVIRONMENT:
29
29
  EE_SECURED = 'EE_SECURED'
30
30
  AIXP_SECURED = 'AIXP_SECURED'
31
31
 
32
- TELEGRAM_BOT_TOKEN_ENV_KEY = 'TELEGRAM_BOT_TOKEN'
33
- TELEGRAM_BOT_NAME_ENV_KEY = 'TELEGRAM_BOT_NAME'
32
+ TELEGRAM_BOT_TOKEN_ENV_KEY = 'EE_TELEGRAM_BOT_TOKEN'
33
+ TELEGRAM_BOT_NAME_ENV_KEY = 'EE_TELEGRAM_BOT_NAME'
34
34
 
35
- TELEGRAM_API_AGENT_TOKEN_ENV_KEY = 'TELEGRAM_API_AGENT_TOKEN'
35
+ TELEGRAM_API_AGENT_TOKEN_ENV_KEY = 'EE_TELEGRAM_API_AGENT_TOKEN'
@@ -21,7 +21,7 @@ EE_MQTT=
21
21
 
22
22
  EE_SECURED=true
23
23
 
24
- TARGET_NODE=
24
+ EE_TARGET_NODE=
25
25
  ```
26
26
 
27
27
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "naeural_client"
7
- version = "2.7.5"
7
+ version = "2.7.7"
8
8
  authors = [
9
9
  { name="Andrei Ionut Damian", email="andrei.damian@me.com" },
10
10
  { name="Cristan Bleotiu", email="cristibleotiu@gmail.com" },
@@ -5,4 +5,4 @@ EE_HOSTNAME=r9092118.ala.eu-central-1.emqxsl.com
5
5
  EE_PORT=8883
6
6
  EE_SECURED=true
7
7
 
8
- TARGET_NODE=0xai....
8
+ EE_TARGET_NODE=0xai....
@@ -46,9 +46,22 @@ class MessageHandler:
46
46
  node_alias = heartbeat[PAYLOAD_DATA.EE_ID]
47
47
  short_addr = self.shorten_address(node_addr)
48
48
  cpu = heartbeat[HEARTBEAT_DATA.CPU]
49
- if node_alias.startswith("mnoderunner"):
50
- self.hb = heartbeat
51
- session.P(f"{node_alias} <{short_addr}> has a {cpu}", color='magenta')
49
+ cpu_load = heartbeat[HEARTBEAT_DATA.CPU_USED]
50
+ mem = heartbeat[HEARTBEAT_DATA.MACHINE_MEMORY]
51
+ mem_avail = heartbeat[HEARTBEAT_DATA.AVAILABLE_MEMORY]
52
+ disk_avail = heartbeat[HEARTBEAT_DATA.AVAILABLE_DISK]
53
+ disk_total = heartbeat[HEARTBEAT_DATA.TOTAL_DISK]
54
+ disk_load = (disk_total - disk_avail) / disk_total * 100
55
+ mem_load = (mem - mem_avail) / mem * 100
56
+ self.hb = heartbeat # simple storage of the last heartbeat
57
+ plugins = heartbeat[HEARTBEAT_DATA.ACTIVE_PLUGINS] or []
58
+ pipelines = heartbeat[HEARTBEAT_DATA.CONFIG_STREAMS] or []
59
+ session.P(
60
+ "<{}> {} {} Load: {:.1f}% CPU, {:.1f}% RAM, {:.1f}% Disk, {} plugins, {} pipelines".format(
61
+ short_addr, node_alias, cpu, cpu_load, mem_load, disk_load, len(plugins), len(pipelines)
62
+ ),
63
+ color='magenta'
64
+ )
52
65
  return
53
66
 
54
67
 
@@ -134,9 +134,13 @@ if __name__ == '__main__':
134
134
 
135
135
  # Observation:
136
136
  # next code is not mandatory - it is used to keep the session open and cleanup the resources
137
- # in production, you would not need this code as the script can close after the pipeline will be sent
138
- session.run(
139
- wait=15, # wait for the user to stop the execution or a given time
140
- close_pipelines=True # when the user stops the execution, the remote edge-node pipelines will be closed
137
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
138
+ # active after the session is closed we use close_pipelines=True
139
+ # in production, you would not need this code as the script can close
140
+ # after the pipeline will be sent
141
+ session.wait(
142
+ seconds=120, # we wait the session for 60 seconds
143
+ close_pipelines=True, # we close the pipelines after the session
144
+ close_session=True, # we close the session after the session
141
145
  )
142
146
  session.P("Main thread exiting...")
@@ -142,7 +142,17 @@ if __name__ == '__main__':
142
142
  # silent=True,
143
143
  )
144
144
 
145
- session.wait(seconds=20) # wait for the user to stop the execution or a given time
145
+ # Observation:
146
+ # next code is not mandatory - it is used to keep the session open and cleanup the resources
147
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
148
+ # active after the session is closed we use close_pipelines=True
149
+ # in production, you would not need this code as the script can close
150
+ # after the pipeline will be sent
151
+ session.wait(
152
+ seconds=120, # we wait the session for 60 seconds
153
+ close_pipelines=True, # we close the pipelines after the session
154
+ close_session=True, # we close the session after the session
155
+ )
146
156
  session.P("Main thread exiting...")
147
157
 
148
158
  netinfo = session.get_network_known_nodes()
@@ -24,7 +24,13 @@ def run_predict(plugin: CustomPluginTemplate, inputs: list[int], nr_steps: int)
24
24
  if __name__ == '__main__':
25
25
 
26
26
  session = Session(silent=True)
27
+
27
28
  my_node = "0xai_ApM1AbzLq1VtsLIidmvzt1Nv4Cyl5Wed0fHNMoZv9u4X"
29
+
30
+ # NOTE: When working with SDK please use the nodes internal addresses. While the EVM address of the node
31
+ # is basically based on the same sk/pk it is in a different format and not directly usable with the SDK
32
+ # the internal node address is easily spoted as starting with 0xai_ and can be found
33
+ # via `docker exec r1node get_node_info` or via the launcher UI
28
34
 
29
35
  app, _ = session.create_web_app(
30
36
  node=my_node,
@@ -42,8 +48,14 @@ if __name__ == '__main__':
42
48
  except Exception as e:
43
49
  print("Error deploying webapp: ", e)
44
50
 
51
+ # Observation:
52
+ # next code is not mandatory - it is used to keep the session open and cleanup the resources
53
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
54
+ # active after the session is closed we use close_pipelines=True
55
+ # in production, you would not need this code as the script can close
56
+ # after the pipeline will be sent
45
57
  session.wait(
46
- close_pipeline_on_timeout=True,
47
- close_session_on_timeout=True,
48
- seconds=300
58
+ seconds=120, # we wait the session for 60 seconds
59
+ close_pipelines=True, # we close the pipelines after the session
60
+ close_session=True, # we close the session after the session
49
61
  )
@@ -20,6 +20,12 @@ def instance_on_data(pipeline: Pipeline, data: Payload):
20
20
  if __name__ == '__main__':
21
21
  # create a session
22
22
  # the network credentials are read from the .env file automatically
23
+
24
+ # NOTE: When working with SDK please use the nodes internal addresses. While the EVM address of the node
25
+ # is basically based on the same sk/pk it is in a different format and not directly usable with the SDK
26
+ # the internal node address is easily spoted as starting with 0xai_ and can be found
27
+ # via `docker exec r1node get_node_info` or via the launcher UI
28
+
23
29
  session: Session = Session(encrypt_comms=True)
24
30
 
25
31
  session.wait_for_any_node()
@@ -57,9 +63,13 @@ if __name__ == '__main__':
57
63
 
58
64
  # Observation:
59
65
  # next code is not mandatory - it is used to keep the session open and cleanup the resources
60
- # in production, you would not need this code as the script can close after the pipeline will be sent
61
- session.run(
62
- wait=60, # wait for the user to stop the execution or a given time
63
- close_pipelines=True # when the user stops the execution, the remote edge-node pipelines will be closed
66
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
67
+ # active after the session is closed we use close_pipelines=True
68
+ # in production, you would not need this code as the script can close
69
+ # after the pipeline will be sent
70
+ session.wait(
71
+ seconds=120, # we wait the session for 60 seconds
72
+ close_pipelines=True, # we close the pipelines after the session
73
+ close_session=True, # we close the session after the session
64
74
  )
65
75
  session.P("Main thread exiting...")
@@ -44,7 +44,7 @@ def predict(plugin: CustomPluginTemplate, series: list[int], steps: int) -> list
44
44
  if __name__ == "__main__":
45
45
  session = Session(silent=True)
46
46
 
47
- node = os.environ.get("TARGET_NODE", "INSERT_YOUR_NODE_ADDRESS_HERE")
47
+ node = os.environ.get("EE_TARGET_NODE", "INSERT_YOUR_NODE_ADDRESS_HERE")
48
48
  session.P(f"Waiting for node {node} to be available for deployment...")
49
49
  session.wait_for_node(node)
50
50
 
@@ -0,0 +1,57 @@
1
+ import os
2
+ import time
3
+
4
+ from naeural_client import Session, CustomPluginTemplate, PLUGIN_TYPES
5
+
6
+ def reply(plugin: CustomPluginTemplate, message: str, user: str):
7
+ """
8
+ This function is used to reply to a message. The given parameters are mandatory
9
+ """
10
+ # for each user message we increase a counter
11
+ plugin.int_cache[user] += 1 # int_cache is a default dict that allows persistence in the plugin
12
+ plugin.P(f"Replying to the {plugin.int_cache[user]} msg of '{user}' on message '{message}'")
13
+ result = f"The answer to your {plugin.int_cache[user]} question is in the question itself: {message}"
14
+ return result
15
+
16
+
17
+ if __name__ == "__main__":
18
+ session = Session()
19
+
20
+ # NOTE: When working with SDK please use the nodes internal addresses. While the EVM address of the node
21
+ # is basically based on the same sk/pk it is in a different format and not directly usable with the SDK
22
+ # the internal node address is easily spoted as starting with 0xai_ and can be found
23
+ # via `docker exec r1node get_node_info` or via the launcher UI
24
+
25
+ # this tutorial assumes you have started your own local node for dev-testing purposes
26
+ # you can either supply the node address via env or directly here
27
+ # Note: in order to get the environment variable first you have to create the Session
28
+ # object that will load the environment variables
29
+ my_node = os.getenv("EE_TARGET_NODE", "0xai_my_own_node_address")
30
+
31
+ session.wait_for_node(my_node)
32
+
33
+
34
+ # now we create a telegram bot pipeline & plugin instance and for that we only need the Telegram token
35
+ # we can chose to use the token directly via `telegram_bot_token` parameter
36
+ # or use the environment key EE_TELEGRAM_BOT_TOKEN
37
+ # in this case for this simple example we are going to use the token directly
38
+ pipeline, _ = session.create_telegram_simple_bot(
39
+ node=my_node,
40
+ name="telegram_bot_echo",
41
+ telegram_bot_token="your_token_goes_here", # we use the token directly
42
+ message_handler=reply,
43
+ )
44
+
45
+ pipeline.deploy() # we deploy the pipeline
46
+
47
+ # Observation:
48
+ # next code is not mandatory - it is used to keep the session open and cleanup the resources
49
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
50
+ # active after the session is closed we use close_pipelines=True
51
+ # in production, you would not need this code as the script can close
52
+ # after the pipeline will be sent
53
+ session.wait(
54
+ seconds=120, # we wait the session for 120 seconds
55
+ close_pipelines=True, # we close the pipelines after the session
56
+ close_session=True, # we close the session after the session
57
+ )
@@ -186,12 +186,20 @@ def reply(plugin, message: str, user: str):
186
186
 
187
187
 
188
188
  if __name__ == "__main__":
189
- my_node = os.getenv("TARGET_NODE") # we can specify a node here, if we want to connect to a specific
190
189
 
191
- session = Session() # assume .env is available and will be used for the connection and tokens
190
+ session = Session()
191
+
192
+ # assume .env is available and will be used for the connection and tokens
193
+ # NOTE: When working with SDK please use the nodes internal addresses. While the EVM address of the node
194
+ # is basically based on the same sk/pk it is in a different format and not directly usable with the SDK
195
+ # the internal node address is easily spoted as starting with 0xai_ and can be found
196
+ # via `docker exec r1node get_node_info` or via the launcher UI
197
+ my_node = os.getenv("EE_TARGET_NODE", "0xai_your_node_address") # we can specify a node here, if we want to connect to a specific
198
+
192
199
  session.wait_for_node(my_node) # wait for the node to be active
193
200
 
194
-
201
+ # unlike the previous example, we are going to use the token from the environment
202
+ # and deploy the app on the target node and leave it there
195
203
  pipeline, _ = session.create_telegram_simple_bot(
196
204
  node=my_node,
197
205
  name="telegram_bot_blackjack",
@@ -200,4 +208,16 @@ if __name__ == "__main__":
200
208
 
201
209
  pipeline.deploy() # we deploy the pipeline
202
210
 
211
+
212
+ # Observation:
213
+ # next code is not mandatory - it is used to keep the session open and cleanup the resources
214
+ # due to the fact that this is a example/tutorial and maybe we dont want to keep the pipeline
215
+ # active after the session is closed we use close_pipelines=True
216
+ # in production, you would not need this code as the script can close
217
+ # after the pipeline will be sent
218
+ session.wait(
219
+ seconds=600, # we wait the session for 10 minutes
220
+ close_pipelines=True, # we close the pipelines after the session
221
+ close_session=True, # we close the session after the session
222
+ )
203
223
 
@@ -2,21 +2,25 @@ import os
2
2
  from naeural_client import Session
3
3
 
4
4
  if __name__ == "__main__":
5
- my_node = os.getenv("TARGET_NODE") # we specify a node here
6
- # The node can also be specified directly, without using the environment variable.
7
- # my_node = "<target_edge_node_identifier>"
8
5
 
9
- if my_node is None:
10
- # In case the node is not specified, we exit the script.
11
- print("Please specify the node to connect to.")
12
- exit(1)
13
-
14
6
  # We define the system prompt
15
7
  SYSTEM_PROMPT = """
16
8
  Hi! I am a simple echo bot. I will repeat everything you say to me.
17
9
  """
18
10
 
19
11
  session = Session() # assume .env is available and will be used for the connection and tokens
12
+
13
+ # NOTE: When working with SDK please use the nodes internal addresses. While the EVM address of the node
14
+ # is basically based on the same sk/pk it is in a different format and not directly usable with the SDK
15
+ # the internal node address is easily spoted as starting with 0xai_ and can be found
16
+ # via `docker exec r1node get_node_info` or via the launcher UI
17
+
18
+ my_node = os.getenv("EE_TARGET_NODE") # we specify a node here
19
+ # The node can also be specified directly, without using the environment variable.
20
+ # my_node = "<target_edge_node_identifier>"
21
+
22
+ assert my_node is not None, "Please provide the target edge node identifier"
23
+
20
24
  session.wait_for_node(my_node) # wait for the node to be active
21
25
 
22
26
  # Now we create a telegram bot pipeline & plugin instance.
@@ -12,8 +12,8 @@ if __name__ == "__main__":
12
12
  session = Session()
13
13
 
14
14
  nodes = [
15
- environ.get("TARGET_NODE_1", "INSERT_YOUR_NODE_ADDRESS_HERE"),
16
- environ.get("TARGET_NODE_2", "INSERT_YOUR_NODE_ADDRESS_HERE")
15
+ environ.get("EE_TARGET_NODE_1", "INSERT_YOUR_NODE_ADDRESS_HERE"),
16
+ environ.get("EE_TARGET_NODE_2", "INSERT_YOUR_NODE_ADDRESS_HERE")
17
17
  ]
18
18
 
19
19
  if isinstance(nodes, str):