naeural-client 2.5.7__py3-none-any.whl → 2.5.9__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 +31 -11
- naeural_client/cli/cli.py +8 -3
- naeural_client/cli/cli_commands.py +3 -2
- naeural_client/cli/nodes.py +14 -8
- naeural_client/utils/config.py +28 -0
- {naeural_client-2.5.7.dist-info → naeural_client-2.5.9.dist-info}/METADATA +1 -1
- {naeural_client-2.5.7.dist-info → naeural_client-2.5.9.dist-info}/RECORD +11 -11
- {naeural_client-2.5.7.dist-info → naeural_client-2.5.9.dist-info}/WHEEL +0 -0
- {naeural_client-2.5.7.dist-info → naeural_client-2.5.9.dist-info}/entry_points.txt +0 -0
- {naeural_client-2.5.7.dist-info → naeural_client-2.5.9.dist-info}/licenses/LICENSE +0 -0
naeural_client/_ver.py
CHANGED
@@ -24,7 +24,9 @@ from .payload import Payload
|
|
24
24
|
from .pipeline import Pipeline
|
25
25
|
from .webapp_pipeline import WebappPipeline
|
26
26
|
from .transaction import Transaction
|
27
|
-
from ..utils.config import
|
27
|
+
from ..utils.config import (
|
28
|
+
load_user_defined_config, get_user_config_file, get_user_folder, seconds_to_short_format
|
29
|
+
)
|
28
30
|
|
29
31
|
# from ..default.instance import PLUGIN_TYPES # circular import
|
30
32
|
|
@@ -571,7 +573,7 @@ class GenericSession(BaseDecentrAIObject):
|
|
571
573
|
sender_addr = dict_msg.get(PAYLOAD_DATA.EE_SENDER, None)
|
572
574
|
path = dict_msg.get(PAYLOAD_DATA.EE_PAYLOAD_PATH, [None, None, None, None])
|
573
575
|
ee_id = dict_msg.get(PAYLOAD_DATA.EE_ID, None)
|
574
|
-
current_network = dict_msg.get(PAYLOAD_DATA.NETMON_CURRENT_NETWORK, {})
|
576
|
+
current_network = dict_msg.get(PAYLOAD_DATA.NETMON_CURRENT_NETWORK, {})
|
575
577
|
if current_network:
|
576
578
|
all_addresses = [
|
577
579
|
x[PAYLOAD_DATA.NETMON_ADDRESS] for x in current_network.values()
|
@@ -1881,14 +1883,16 @@ class GenericSession(BaseDecentrAIObject):
|
|
1881
1883
|
"""
|
1882
1884
|
|
1883
1885
|
ngrok_use_api = True
|
1884
|
-
use_ngrok=True
|
1886
|
+
use_ngrok = True
|
1887
|
+
kwargs.pop('use_ngrok', None)
|
1888
|
+
kwargs.pop('ngrok_use_api', None)
|
1885
1889
|
|
1886
1890
|
# if isinstance(signature, str):
|
1887
1891
|
|
1888
1892
|
pipelines, instances = [], []
|
1889
1893
|
|
1890
1894
|
for node in nodes:
|
1891
|
-
self.P("Creating web app on node {}...".format(node), color='
|
1895
|
+
self.P("Creating web app on node {}...".format(node), color='b')
|
1892
1896
|
pipeline: WebappPipeline = self.create_pipeline(
|
1893
1897
|
node=nodes[0],
|
1894
1898
|
name=name,
|
@@ -2230,7 +2234,14 @@ class GenericSession(BaseDecentrAIObject):
|
|
2230
2234
|
def client_address(self):
|
2231
2235
|
return self.get_client_address()
|
2232
2236
|
|
2233
|
-
def get_network_known_nodes(
|
2237
|
+
def get_network_known_nodes(
|
2238
|
+
self,
|
2239
|
+
timeout=10,
|
2240
|
+
online_only=False,
|
2241
|
+
supervisors_only=False,
|
2242
|
+
min_supervisors=2,
|
2243
|
+
supervisor=None,
|
2244
|
+
):
|
2234
2245
|
"""
|
2235
2246
|
This function will return a Pandas dataframe known nodes in the network based on
|
2236
2247
|
all the net-mon messages received so far.
|
@@ -2238,10 +2249,10 @@ class GenericSession(BaseDecentrAIObject):
|
|
2238
2249
|
mapping = OrderedDict({
|
2239
2250
|
'Address': PAYLOAD_DATA.NETMON_ADDRESS,
|
2240
2251
|
'Alias' : PAYLOAD_DATA.NETMON_EEID,
|
2252
|
+
'Seen ago' : PAYLOAD_DATA.NETMON_LAST_SEEN,
|
2241
2253
|
'Last state': PAYLOAD_DATA.NETMON_STATUS_KEY,
|
2242
|
-
'Ago (s)' : PAYLOAD_DATA.NETMON_LAST_SEEN,
|
2243
2254
|
'Last probe' : PAYLOAD_DATA.NETMON_LAST_REMOTE_TIME,
|
2244
|
-
'
|
2255
|
+
'Zone' : PAYLOAD_DATA.NETMON_NODE_UTC,
|
2245
2256
|
'Supervisor' : PAYLOAD_DATA.NETMON_IS_SUPERVISOR,
|
2246
2257
|
})
|
2247
2258
|
reverse_mapping = {v: k for k, v in mapping.items()}
|
@@ -2249,8 +2260,12 @@ class GenericSession(BaseDecentrAIObject):
|
|
2249
2260
|
for k in mapping:
|
2250
2261
|
res[k] = []
|
2251
2262
|
start = tm()
|
2263
|
+
|
2252
2264
|
while (tm() - start) < timeout:
|
2253
|
-
if
|
2265
|
+
if supervisor is not None:
|
2266
|
+
if supervisor in self.__current_network_statuses:
|
2267
|
+
break
|
2268
|
+
elif len(self.__current_network_statuses) >= min_supervisors:
|
2254
2269
|
break
|
2255
2270
|
sleep(0.1)
|
2256
2271
|
# end while
|
@@ -2273,10 +2288,15 @@ class GenericSession(BaseDecentrAIObject):
|
|
2273
2288
|
val = node_info.get(key, None)
|
2274
2289
|
if key == PAYLOAD_DATA.NETMON_LAST_REMOTE_TIME:
|
2275
2290
|
# val hols a string '2024-12-23 23:50:16.462155' and must be converted to a datetime
|
2276
|
-
val = dt.strptime(val, '%Y-%m-%d %H:%M:%S.%f')
|
2277
|
-
# strip the microseconds
|
2278
|
-
|
2291
|
+
val = dt.strptime(val, '%Y-%m-%d %H:%M:%S.%f')
|
2292
|
+
val = val.replace(microsecond=0) # strip the microseconds
|
2293
|
+
elif key == PAYLOAD_DATA.NETMON_LAST_SEEN:
|
2294
|
+
# convert val (seconds) to a human readable format
|
2295
|
+
val = seconds_to_short_format(val)
|
2296
|
+
elif key == PAYLOAD_DATA.NETMON_ADDRESS:
|
2297
|
+
val = self.bc_engine._add_prefix(val)
|
2279
2298
|
res[column].append(val)
|
2280
2299
|
# end for
|
2281
2300
|
# end if
|
2301
|
+
pd.options.display.float_format = '{:.1f}'.format
|
2282
2302
|
return pd.DataFrame(res), best_super
|
naeural_client/cli/cli.py
CHANGED
@@ -52,9 +52,14 @@ def build_parser():
|
|
52
52
|
if isinstance(subcmd_info, dict) and "params" in subcmd_info:
|
53
53
|
for param, description in subcmd_info["params"].items():
|
54
54
|
if param.startswith("--"):
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
if description.upper().endswith("FLAG"):
|
56
|
+
subcommand_parser.add_argument(
|
57
|
+
param, action="store_true", help=description
|
58
|
+
)
|
59
|
+
else:
|
60
|
+
subcommand_parser.add_argument(
|
61
|
+
param, help=description, type=str
|
62
|
+
)
|
58
63
|
else:
|
59
64
|
subcommand_parser.add_argument(
|
60
65
|
param, help=description
|
@@ -11,9 +11,10 @@ CLI_COMMANDS = {
|
|
11
11
|
"nodes": {
|
12
12
|
"func": get_nodes,
|
13
13
|
"params": {
|
14
|
-
"--all": "Get all known nodes", # DONE
|
15
|
-
"--online" : "Get only online nodes", # DONE
|
14
|
+
"--all": "Get all known nodes flag", # DONE
|
15
|
+
"--online" : "Get only online nodes flag", # DONE
|
16
16
|
# "--peered": "Get only peered nodes"
|
17
|
+
"--supervisor" : "Use a specific supervisor node"
|
17
18
|
}
|
18
19
|
},
|
19
20
|
"supervisors": {
|
naeural_client/cli/nodes.py
CHANGED
@@ -10,21 +10,26 @@ def get_nodes(args):
|
|
10
10
|
3. Wait for the second net mon message via Session and show progress.
|
11
11
|
4. Get the active nodes union via Session and display the nodes marking those peered vs non-peered.
|
12
12
|
"""
|
13
|
+
supervisor_addr = args.supervisor
|
13
14
|
if args.verbose:
|
14
|
-
log_with_color("Getting nodes
|
15
|
+
log_with_color(f"Getting nodes from supervisor <{supervisor_addr}>...", color='b')
|
15
16
|
from naeural_client import Session
|
16
17
|
sess = Session(silent=not args.verbose)
|
17
18
|
if args.all:
|
18
|
-
df, supervisor = sess.get_network_known_nodes()
|
19
|
-
log_with_color(f"Network
|
19
|
+
df, supervisor = sess.get_network_known_nodes(supervisor=supervisor_addr)
|
20
|
+
log_with_color(f"Network full map reported by <{supervisor}>:", color='b')
|
20
21
|
log_with_color(f"{df}")
|
21
22
|
elif args.online:
|
22
|
-
df, supervisor = sess.get_network_known_nodes(
|
23
|
-
|
23
|
+
df, supervisor = sess.get_network_known_nodes(
|
24
|
+
online_only=True, supervisor=supervisor_addr
|
25
|
+
)
|
26
|
+
log_with_color(f"Online nodes reported by <{supervisor}>:", color='b')
|
24
27
|
log_with_color(f"{df}")
|
25
28
|
else:
|
26
|
-
df, supervisor = sess.get_network_known_nodes(
|
27
|
-
|
29
|
+
df, supervisor = sess.get_network_known_nodes(
|
30
|
+
online_only=True, supervisor=supervisor_addr
|
31
|
+
)
|
32
|
+
log_with_color(f"Online nodes reported by <{supervisor}>:", color='b')
|
28
33
|
log_with_color(f"{df}")
|
29
34
|
return
|
30
35
|
|
@@ -38,7 +43,8 @@ def get_supervisors(args):
|
|
38
43
|
from naeural_client import Session
|
39
44
|
sess = Session(silent=not args.verbose)
|
40
45
|
df, supervisor = sess.get_network_known_nodes(online_only=True, supervisors_only=True)
|
41
|
-
log_with_color(f"Supervisors reported by <{supervisor}
|
46
|
+
log_with_color(f"Supervisors reported by <{supervisor}>", color='b')
|
47
|
+
log_with_color(f"{df}")
|
42
48
|
return
|
43
49
|
|
44
50
|
|
naeural_client/utils/config.py
CHANGED
@@ -14,6 +14,34 @@ EE_SECURED=true
|
|
14
14
|
TARGET_NODE=
|
15
15
|
"""
|
16
16
|
|
17
|
+
def seconds_to_short_format(seconds):
|
18
|
+
"""
|
19
|
+
Converts a duration in seconds into a short human-readable format: "Xd HH:MM:SS".
|
20
|
+
|
21
|
+
Parameters
|
22
|
+
----------
|
23
|
+
seconds : int
|
24
|
+
The total duration in seconds.
|
25
|
+
|
26
|
+
Returns
|
27
|
+
-------
|
28
|
+
str
|
29
|
+
Short human-readable duration in "Xd HH:MM:SS" format.
|
30
|
+
"""
|
31
|
+
days = int(seconds / (24 * 3600))
|
32
|
+
seconds %= (24 * 3600)
|
33
|
+
hours = int(seconds / 3600)
|
34
|
+
seconds %= 3600
|
35
|
+
minutes = int(seconds / 60)
|
36
|
+
seconds %= 60
|
37
|
+
seconds = int(seconds)
|
38
|
+
|
39
|
+
# Format the result
|
40
|
+
if days > 0:
|
41
|
+
return f"{days}d {hours:02}:{minutes:02}:{seconds:02}"
|
42
|
+
else:
|
43
|
+
return f"{hours:02}:{minutes:02}:{seconds:02}"
|
44
|
+
|
17
45
|
def log_with_color(s, color='n'):
|
18
46
|
"""
|
19
47
|
Prints the string `s` to the console in the specified color.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: naeural_client
|
3
|
-
Version: 2.5.
|
3
|
+
Version: 2.5.9
|
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,10 +1,10 @@
|
|
1
1
|
naeural_client/__init__.py,sha256=GP8WSrn87sjTPO-QRNL2PG8JK5Mixbiea_HrtbG8RAQ,592
|
2
|
-
naeural_client/_ver.py,sha256=
|
2
|
+
naeural_client/_ver.py,sha256=l2hQhFUtxGvo4zX1x7oPvnNzaZHD797T0pCICqMPFRM,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=
|
7
|
+
naeural_client/base/generic_session.py,sha256=3pvPZCIiygD-QWggmWUOZWj52o6la5koEYd2R-OF9YQ,85692
|
8
8
|
naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
|
9
9
|
naeural_client/base/pipeline.py,sha256=b4uNHrEIOlAtw4PGUx20dxwBhDck5__SrVXaHcSi8ZA,58251
|
10
10
|
naeural_client/base/plugin_template.py,sha256=qGaXByd_JZFpjvH9GXNbT7KaitRxIJB6-1IhbKrZjq4,138123
|
@@ -20,9 +20,9 @@ naeural_client/bc/ec.py,sha256=mWjodWCRgC3omVXOA9jtNdtPVNn2kMKV3Dcjt9oFUCQ,22974
|
|
20
20
|
naeural_client/certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
naeural_client/certs/r9092118.ala.eu-central-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1gPULtJNSYUpG_YFkYaMKU,1337
|
22
22
|
naeural_client/cli/README.md,sha256=WPdI_EjzAbUW1aPyj1sSR8rLydcJKZtoiaEtklQrjHo,74
|
23
|
-
naeural_client/cli/cli.py,sha256=
|
24
|
-
naeural_client/cli/cli_commands.py,sha256=
|
25
|
-
naeural_client/cli/nodes.py,sha256=
|
23
|
+
naeural_client/cli/cli.py,sha256=GyQhw16LrCbXU0JLH0HlbyYvKqa15K5RIhQ-Pgi7Gy4,3752
|
24
|
+
naeural_client/cli/cli_commands.py,sha256=BtByinaxFvThyQdeu8Moz2aMioR5MW5GTiI1bGjbfwQ,1392
|
25
|
+
naeural_client/cli/nodes.py,sha256=Q26sJpDCOd0oqpNonqEoCc1EcLVnf2CaGFzrG1wyzhA,2363
|
26
26
|
naeural_client/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
|
27
27
|
naeural_client/code_cheker/base.py,sha256=lT5DRIFO5rqzsMNCmdMRfkAeevmezozehyfgmhnKpuI,19074
|
28
28
|
naeural_client/code_cheker/checker.py,sha256=QWupeM7ToancVIq1tRUxRNUrI8B5l5eoY0kDU4-O5aE,7365
|
@@ -79,10 +79,10 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
|
|
79
79
|
naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
|
80
80
|
naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
|
81
81
|
naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
|
82
|
-
naeural_client/utils/config.py,sha256=
|
82
|
+
naeural_client/utils/config.py,sha256=aUVyi5rZjvnbUwM5mmj0E2IHvURdrlHSgleqZvJBNuU,5202
|
83
83
|
naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
|
84
|
-
naeural_client-2.5.
|
85
|
-
naeural_client-2.5.
|
86
|
-
naeural_client-2.5.
|
87
|
-
naeural_client-2.5.
|
88
|
-
naeural_client-2.5.
|
84
|
+
naeural_client-2.5.9.dist-info/METADATA,sha256=96hKd3KQ2t71LFr44aKxSpBfta5f2CYAcWcvA6Vx1x8,14493
|
85
|
+
naeural_client-2.5.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
86
|
+
naeural_client-2.5.9.dist-info/entry_points.txt,sha256=PNdyotDaQBAslZREx5luVyj0kqpQnwNACwkFNTPIHU4,55
|
87
|
+
naeural_client-2.5.9.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
|
88
|
+
naeural_client-2.5.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|