naeural-client 3.0.5__py3-none-any.whl → 3.0.7__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__ = "3.0.5"
1
+ __VER__ = "3.0.7"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -89,7 +89,7 @@ class GenericSession(BaseDecentrAIObject):
89
89
  on_notification=None,
90
90
  on_heartbeat=None,
91
91
  debug_silent=True,
92
- debug=False,
92
+ debug=1,
93
93
  silent=False,
94
94
  verbosity=1,
95
95
  dotenv_path=None,
@@ -145,6 +145,7 @@ class GenericSession(BaseDecentrAIObject):
145
145
  As arguments, it has a reference to this Session object, the node name, the pipeline, signature and instance, and the payload.
146
146
  This callback acts as a default payload processor and will be called even if for a given instance
147
147
  the user has defined a specific callback.
148
+
148
149
  on_notification : Callable[[Session, str, dict], None], optional
149
150
  Callback that handles notifications received from this network.
150
151
  As arguments, it has a reference to this Session object, the node name and the notification payload.
@@ -153,6 +154,7 @@ class GenericSession(BaseDecentrAIObject):
153
154
  This callback will be called when there are notifications related to the node itself, e.g. when the node runs
154
155
  low on memory.
155
156
  Defaults to None.
157
+
156
158
  on_heartbeat : Callable[[Session, str, dict], None], optional
157
159
  Callback that handles heartbeats received from this network.
158
160
  As arguments, it has a reference to this Session object, the node name and the heartbeat payload.
@@ -162,8 +164,12 @@ class GenericSession(BaseDecentrAIObject):
162
164
  This flag will disable debug logs, set to 'False` for a more verbose log, by default True
163
165
  Observation: Obsolete, will be removed
164
166
 
165
- debug : bool, optional
166
- This flag will enable debug logs, set to 'False` for a more verbose log, by default False
167
+ debug : bool or int, optional
168
+ This flag will enable debug logs, set to 'True` or 2 for a more verbose log, by default 1
169
+ - 0 or False will disable debug logs
170
+ - 1 will enable level 1
171
+ - 2 will enable full debug
172
+
167
173
 
168
174
 
169
175
  silent : bool, optional
@@ -185,8 +191,11 @@ class GenericSession(BaseDecentrAIObject):
185
191
  If True, the SDK will use the home folder as the base folder for the local cache.
186
192
  NOTE: if you need to use development style ./_local_cache, set this to False.
187
193
  """
188
-
189
194
  debug = debug or not debug_silent
195
+ if isinstance(debug, bool):
196
+ debug = 2 if debug else 0
197
+
198
+ self.__debug = int(debug) > 0
190
199
 
191
200
  self.__at_least_one_node_peered = False
192
201
  self.__at_least_a_netmon_received = False
@@ -278,13 +287,20 @@ class GenericSession(BaseDecentrAIObject):
278
287
 
279
288
  super(GenericSession, self).__init__(
280
289
  log=log,
281
- DEBUG=debug,
290
+ DEBUG=int(debug) > 1,
282
291
  create_logger=True,
283
292
  silent=self.silent,
284
293
  local_cache_base_folder=local_cache_base_folder,
285
294
  local_cache_app_folder=local_cache_app_folder,
286
295
  )
287
296
  return
297
+
298
+ def Pd(self, *args, **kwargs):
299
+ if self.__debug:
300
+ kwargs["color"] = 'd' if kwargs.get("color") != 'r' else 'r'
301
+ self.log.P(*args, **kwargs)
302
+ return
303
+
288
304
 
289
305
  def startup(self):
290
306
  ## 1st config step - we prepare config via ~/.naeural/config or .env
@@ -830,7 +846,7 @@ class GenericSession(BaseDecentrAIObject):
830
846
  if needs_netconfig:
831
847
  lst_netconfig_request.append(node_addr)
832
848
  # end for each node in network map
833
- self.P(f"Net mon from <{sender_addr}> `{ee_id}`: {len(online_addresses)}/{len(all_addresses)}", color='y')
849
+ self.Pd(f"Net mon from <{sender_addr}> `{ee_id}`: {len(online_addresses)}/{len(all_addresses)}")
834
850
  if len(lst_netconfig_request) > 0:
835
851
  self.__request_pipelines_from_net_config_monitor(lst_netconfig_request)
836
852
  # end if needs netconfig
@@ -1607,7 +1623,7 @@ class GenericSession(BaseDecentrAIObject):
1607
1623
  )
1608
1624
  self.bc_engine.sign(msg_to_send, use_digest=True)
1609
1625
  if show_command:
1610
- self.P(
1626
+ self.Pd(
1611
1627
  "Sending command '{}' to '{}':\n{}".format(command, worker, json.dumps(msg_to_send, indent=2)),
1612
1628
  color='y',
1613
1629
  verbosity=1
@@ -1778,6 +1794,7 @@ class GenericSession(BaseDecentrAIObject):
1778
1794
  on_notification=None,
1779
1795
  max_wait_time=0,
1780
1796
  pipeline_type=None,
1797
+ debug=False,
1781
1798
  **kwargs) -> Pipeline:
1782
1799
  """
1783
1800
  Create a new pipeline on a node. A pipeline is the equivalent of the "config file" used by the Naeural Edge Protocol edge node team internally.
@@ -1857,6 +1874,7 @@ class GenericSession(BaseDecentrAIObject):
1857
1874
  on_data=on_data,
1858
1875
  on_notification=on_notification,
1859
1876
  is_attached=False,
1877
+ debug=debug,
1860
1878
  **kwargs
1861
1879
  )
1862
1880
  self.own_pipelines.append(pipeline)
@@ -9,7 +9,19 @@ class Instance():
9
9
  The Instance class is a wrapper around a plugin instance. It provides a simple API for sending commands to the instance and updating its configuration.
10
10
  """
11
11
 
12
- def __init__(self, log, pipeline, instance_id, signature, on_data=None, on_notification=None, config={}, is_attached=False, **kwargs):
12
+ def __init__(
13
+ self,
14
+ log,
15
+ pipeline,
16
+ instance_id,
17
+ signature,
18
+ on_data=None,
19
+ on_notification=None,
20
+ config={},
21
+ is_attached=False,
22
+ debug=False,
23
+ **kwargs
24
+ ):
13
25
  """
14
26
  Create a new instance of the plugin.
15
27
 
@@ -39,6 +51,7 @@ class Instance():
39
51
  self.instance_id = instance_id
40
52
  self.signature = signature.upper()
41
53
  self.config = {}
54
+ self.__debug = debug
42
55
 
43
56
  if is_attached:
44
57
  assert len(kwargs) == 0, "When attaching an instance, no additional parameters are allowed"
@@ -61,6 +74,12 @@ class Instance():
61
74
  self.on_notification_callbacks.append(on_notification)
62
75
 
63
76
  return
77
+
78
+ def Pd(self, *args, **kwargs):
79
+ if self.__debug:
80
+ kwargs["color"] = 'd' if kwargs.get("color") != 'r' else 'r'
81
+ self.log.P(*args, **kwargs)
82
+ return
64
83
 
65
84
  # Message handling
66
85
  if True:
@@ -75,6 +94,7 @@ class Instance():
75
94
  data : dict | Payload
76
95
  The data received from the instance
77
96
  """
97
+ self.Pd(f"_on_data: {pipeline.name}:{self.signature}:{self.instance_id}")
78
98
  for callback in self.on_data_callbacks:
79
99
  callback(pipeline, data)
80
100
  for callback in self.temporary_on_data_callbacks.values():
@@ -503,7 +523,7 @@ class Instance():
503
523
  The list of transactions generated, or None if `wait_confirmation` is False.
504
524
 
505
525
  """
506
- self.P(f'Sending command <{command}> to instance <{self.__repr__()}>', color="b")
526
+ self.Pd(f'Sending command <{command}> to instance <{self.__repr__()}>', color="b")
507
527
 
508
528
  self.__was_last_operation_successful = None
509
529
 
@@ -40,6 +40,7 @@ class Pipeline(BaseCodeChecker):
40
40
  on_notification=None,
41
41
  is_attached=False,
42
42
  existing_config=None,
43
+ debug=False,
43
44
  **kwargs
44
45
  ) -> None:
45
46
  """
@@ -99,6 +100,7 @@ class Pipeline(BaseCodeChecker):
99
100
  self.session = session
100
101
  self.node_addr = node_addr
101
102
  self.name = name
103
+ self.__debug = debug
102
104
 
103
105
  self.config = {}
104
106
  plugins = config.pop('PLUGINS', plugins)
@@ -148,10 +150,28 @@ class Pipeline(BaseCodeChecker):
148
150
 
149
151
  self.__init_plugins(plugins, is_attached)
150
152
  return
153
+
154
+ def Pd(self, *args, **kwargs):
155
+ """
156
+ Print debug message.
157
+ """
158
+ if self.__debug:
159
+ kwargs["color"] = 'd' if kwargs.get("color") != 'r' else 'r'
160
+ self.P(*args, **kwargs)
161
+ return
151
162
 
152
163
  # Utils
153
164
  if True:
154
- def __init_instance(self, signature, instance_id, config, on_data, on_notification, is_attached):
165
+ def __init_instance(
166
+ self,
167
+ signature,
168
+ instance_id,
169
+ config,
170
+ on_data,
171
+ on_notification,
172
+ is_attached,
173
+ debug=False,
174
+ ):
155
175
  instance_class = None
156
176
  str_signature = None
157
177
  if isinstance(signature, str):
@@ -160,15 +180,17 @@ class Pipeline(BaseCodeChecker):
160
180
  else:
161
181
  instance_class = signature
162
182
  str_signature = instance_class.signature.upper()
163
- instance = instance_class(self.log,
164
- pipeline=self,
165
- signature=str_signature,
166
- instance_id=instance_id,
167
- config=config,
168
- on_data=on_data,
169
- on_notification=on_notification,
170
- is_attached=is_attached
171
- )
183
+ instance = instance_class(
184
+ self.log,
185
+ pipeline=self,
186
+ signature=str_signature,
187
+ instance_id=instance_id,
188
+ config=config,
189
+ on_data=on_data,
190
+ on_notification=on_notification,
191
+ is_attached=is_attached,
192
+ debug=debug,
193
+ )
172
194
  self.lst_plugin_instances.append(instance)
173
195
  return instance
174
196
 
@@ -710,6 +732,7 @@ class Pipeline(BaseCodeChecker):
710
732
  The payload of the message.
711
733
  """
712
734
  # call all self callbacks
735
+ self.Pd(f"Pipeline <{self.name}> received data from <{signature}:{instance_id}>")
713
736
  for callback in self.on_data_callbacks:
714
737
  callback(self, signature, instance_id, data)
715
738
 
@@ -834,6 +857,7 @@ class Pipeline(BaseCodeChecker):
834
857
  config={},
835
858
  on_data=None,
836
859
  on_notification=None,
860
+ debug=False,
837
861
  **kwargs
838
862
  ) -> Instance:
839
863
  """
@@ -884,7 +908,11 @@ class Pipeline(BaseCodeChecker):
884
908
 
885
909
  # create the new instance and add it to the list
886
910
  config = {**config, **kwargs}
887
- instance = self.__init_instance(signature, instance_id, config, on_data, on_notification, is_attached=False)
911
+ instance = self.__init_instance(
912
+ signature=signature, instance_id=instance_id, config=config,
913
+ on_data=on_data, on_notification=on_notification, is_attached=False,
914
+ debug=debug
915
+ )
888
916
  return instance
889
917
 
890
918
  def __remove_plugin_instance(self, instance):
@@ -268,8 +268,8 @@ class R1FSEngine:
268
268
 
269
269
  def _get_unique_or_complete_upload_name(self, fn=None, prefix="r1fs", suffix=""):
270
270
  if fn is not None and os.path.dirname(fn) == "":
271
- return os.path.join(self.__uploads_dir, fn)
272
- return self._get_unique_upload_name(prefix, suffix)
271
+ return os.path.join(self.__uploads_dir, f"{fn}{suffix}")
272
+ return self._get_unique_upload_name(prefix, suffix=suffix)
273
273
 
274
274
  def __set_reprovider_interval(self):
275
275
  # Command to set the Reprovider.Interval to 1 minute
@@ -566,6 +566,7 @@ class R1FSEngine:
566
566
  msg += f"\n Download: {self.__downloads_dir}"
567
567
  msg += f"\n Upload: {self.__uploads_dir}"
568
568
  msg += f"\n SwarmKey: {hidden_base64_swarm_key}"
569
+ msg += f"\n Debug: {self.__debug}"
569
570
  self.P(msg, color='d')
570
571
 
571
572
  ipfs_repo = os.path.expanduser("~/.ipfs")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 3.0.5
3
+ Version: 3.0.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,12 +1,12 @@
1
1
  naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=s1jPVva_BCSPVAGwO54_7WPVxWZY3vssZ-Ouo0c4jwY,330
2
+ naeural_client/_ver.py,sha256=OPLz5MVG0CNDQKO3wg7bABmsaCfJEnDBjWTzSQG15qk,330
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=VCJb2gni2qtqqrYn68iG0MfaqsSQVBkj_XcHV3dLngg,115453
8
- naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
9
- naeural_client/base/pipeline.py,sha256=b4BJlqZ4vsGNqYPjJD9Uzrv5G8CVYG_jbND5rh_s8E0,59702
7
+ naeural_client/base/generic_session.py,sha256=UVrcCfq9W-wBCF8b3XTFtNzXJ2NDaBJKPx5NWwIW1Xk,115925
8
+ naeural_client/base/instance.py,sha256=bDb9y9ez1vLEGGOCAACQoil7Dw-h7UAwCc18IEfqEas,20789
9
+ naeural_client/base/pipeline.py,sha256=GYqDd59QQEn7_MTM_dhWsZtdit5q3rECC8HEivWXowo,60068
10
10
  naeural_client/base/plugin_template.py,sha256=7YAFaND2iXoZLgtunjYkFf_TBGieFr3VdNLO3vCqzmM,138795
11
11
  naeural_client/base/responses.py,sha256=ZKBZmRhYDv8M8mQ5C_ahGsQvtWH4b9ImRcuerQdZmNw,6937
12
12
  naeural_client/base/transaction.py,sha256=bfs6td5M0fINgPQNxhrl_AUjb1YiilLDQ-Cd_o3OR_E,5146
@@ -62,7 +62,7 @@ naeural_client/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz
62
62
  naeural_client/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
63
63
  naeural_client/ipfs/__init__.py,sha256=vXEDLUNUO6lOTMGa8iQ9Zf7ajIQq9GZuvYraAHt3meE,38
64
64
  naeural_client/ipfs/ifps_keygen,sha256=PcoYuo4c89_C9FWrKq9K_28ruhKqnxNn1s3nLHiF1tc,879
65
- naeural_client/ipfs/r1fs.py,sha256=ovBOG81tPdWv3M7bPGZwrJylDDNSzQ8K4t04HNe2EZ0,19328
65
+ naeural_client/ipfs/r1fs.py,sha256=voZSoWN07OB-AmSc0WVEngQqyxogmG5ERFOQLOovPhg,19391
66
66
  naeural_client/ipfs/ipfs_setup/ipfs.service,sha256=isTJQsktPy4i1yaDA9AC1OKdlTYvsCCRRAVX-EmGqAs,248
67
67
  naeural_client/ipfs/ipfs_setup/launch_service.sh,sha256=GWhZyNqtohLxJg8Q_c8YnNZduu1ddXDU-IFRRMaEyiY,141
68
68
  naeural_client/ipfs/ipfs_setup/restart.sh,sha256=9xHMgkUoAMI25jeaoDVFbCa_LjojYm3ubljW58RatKE,22
@@ -96,8 +96,8 @@ naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_L
96
96
  naeural_client/utils/config.py,sha256=upTCJWpZ-Or8V_71DHrIZ429LKn08KNySKcw0WIADcc,10348
97
97
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
98
98
  naeural_client/utils/oracle_sync/oracle_tester.py,sha256=X-923ccjkr6_kzbbiuAAcWSIhMtBDOH2VURjTh55apQ,27235
99
- naeural_client-3.0.5.dist-info/METADATA,sha256=tElTUOP4AP53xuvMJTA2KSCZZ0Kxm5S174a5s2Fl-fM,12353
100
- naeural_client-3.0.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
101
- naeural_client-3.0.5.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
102
- naeural_client-3.0.5.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
103
- naeural_client-3.0.5.dist-info/RECORD,,
99
+ naeural_client-3.0.7.dist-info/METADATA,sha256=KVJVFkcGJk5qGxCuKHzww_JJS7v-P3GVaYHERlroykU,12353
100
+ naeural_client-3.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
101
+ naeural_client-3.0.7.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
102
+ naeural_client-3.0.7.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
103
+ naeural_client-3.0.7.dist-info/RECORD,,