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 +1 -1
- naeural_client/base/generic_session.py +25 -7
- naeural_client/base/instance.py +22 -2
- naeural_client/base/pipeline.py +39 -11
- naeural_client/ipfs/r1fs.py +3 -2
- {naeural_client-3.0.5.dist-info → naeural_client-3.0.7.dist-info}/METADATA +1 -1
- {naeural_client-3.0.5.dist-info → naeural_client-3.0.7.dist-info}/RECORD +10 -10
- {naeural_client-3.0.5.dist-info → naeural_client-3.0.7.dist-info}/WHEEL +0 -0
- {naeural_client-3.0.5.dist-info → naeural_client-3.0.7.dist-info}/entry_points.txt +0 -0
- {naeural_client-3.0.5.dist-info → naeural_client-3.0.7.dist-info}/licenses/LICENSE +0 -0
naeural_client/_ver.py
CHANGED
@@ -89,7 +89,7 @@ class GenericSession(BaseDecentrAIObject):
|
|
89
89
|
on_notification=None,
|
90
90
|
on_heartbeat=None,
|
91
91
|
debug_silent=True,
|
92
|
-
debug=
|
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 '
|
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.
|
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.
|
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)
|
naeural_client/base/instance.py
CHANGED
@@ -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__(
|
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.
|
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
|
|
naeural_client/base/pipeline.py
CHANGED
@@ -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(
|
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(
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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(
|
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):
|
naeural_client/ipfs/r1fs.py
CHANGED
@@ -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.
|
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=
|
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=
|
8
|
-
naeural_client/base/instance.py,sha256=
|
9
|
-
naeural_client/base/pipeline.py,sha256=
|
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=
|
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.
|
100
|
-
naeural_client-3.0.
|
101
|
-
naeural_client-3.0.
|
102
|
-
naeural_client-3.0.
|
103
|
-
naeural_client-3.0.
|
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,,
|
File without changes
|
File without changes
|
File without changes
|