naeural-client 2.6.41__py3-none-any.whl → 2.7.1__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__ = "2.6.41"
1
+ __VER__ = "2.7.1"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -1191,7 +1191,7 @@ class GenericSession(BaseDecentrAIObject):
1191
1191
 
1192
1192
  def __load_user_config(self, dotenv_path):
1193
1193
  # if the ~/.naeural/config file exists, load the credentials from there else try to load them from .env
1194
- if not load_user_defined_config():
1194
+ if not load_user_defined_config(verbose=not self.log.silent):
1195
1195
  # this method will search for the credentials in the environment variables
1196
1196
  # the path to env file, if not specified, will be search in the following order:
1197
1197
  # 1. current working directory
naeural_client/bc/base.py CHANGED
@@ -20,8 +20,8 @@ from ..utils.config import get_user_folder
20
20
 
21
21
  from ..const.base import (
22
22
  BCctbase, BCct,
23
- DAUTH_SUBKEY, DAUTH_URL, DAUTH_ENV_KEY,
24
- DAUTH_NONCE, DAUTH_VARS, dAuth,
23
+ DAUTH_SUBKEY, DAUTH_ENV_KEY,
24
+ DAUTH_NONCE, dAuth,
25
25
  )
26
26
 
27
27
 
@@ -1409,7 +1409,7 @@ class BaseBlockEngine:
1409
1409
 
1410
1410
 
1411
1411
  @staticmethod
1412
- def web3_is_node_licensed(address : str, network='mainnet') -> bool:
1412
+ def web3_is_node_licensed(address : str, network=None) -> bool:
1413
1413
  """
1414
1414
  Check if the address is allowed to send commands to the node
1415
1415
 
@@ -1418,6 +1418,9 @@ class BaseBlockEngine:
1418
1418
  address : str
1419
1419
  the address to check.
1420
1420
  """
1421
+ if network is None:
1422
+ network = os.environ.get(dAuth.DAUTH_NET_ENV_KEY, dAuth.DAUTH_SDK_NET_DEFAULT)
1423
+
1421
1424
  assert network.lower() in ['mainnet', 'testnet'], f"Invalid network {network}"
1422
1425
 
1423
1426
  assert BaseBlockEngine.is_valid_eth_address(address), "Invalid Ethereum address"
@@ -1439,14 +1442,14 @@ class BaseBlockEngine:
1439
1442
  return result
1440
1443
 
1441
1444
 
1442
- def web3_get_oracles(self, network='mainnet') -> list:
1445
+ def web3_get_oracles(self, network=None) -> list:
1443
1446
  """
1444
1447
  Get the list of oracles from the contract
1445
1448
 
1446
1449
  Parameters
1447
1450
  ----------
1448
1451
  network : str, optional
1449
- the network to use. The default is 'mainnet'.
1452
+ the network to use. The default is None.
1450
1453
 
1451
1454
  Returns
1452
1455
  -------
@@ -1454,6 +1457,9 @@ class BaseBlockEngine:
1454
1457
  the list of oracles addresses.
1455
1458
 
1456
1459
  """
1460
+ if network is None:
1461
+ network = os.environ.get(dAuth.DAUTH_NET_ENV_KEY, dAuth.DAUTH_SDK_NET_DEFAULT)
1462
+
1457
1463
  assert network.lower() in ['mainnet', 'testnet'], f"Invalid network {network}"
1458
1464
 
1459
1465
  if network.lower() == 'mainnet':
@@ -1482,7 +1488,8 @@ class BaseBlockEngine:
1482
1488
  dauth_endp=None,
1483
1489
  add_env=True,
1484
1490
  debug=False,
1485
- max_tries=5,
1491
+ max_tries=5,
1492
+ network=None,
1486
1493
  **kwargs
1487
1494
  ):
1488
1495
  from naeural_client._ver import __VER__ as sdk_version
@@ -1503,14 +1510,20 @@ class BaseBlockEngine:
1503
1510
  url = dauth_endp
1504
1511
  dct_response = {}
1505
1512
 
1513
+ if network is None:
1514
+ network = os.environ.get(dAuth.DAUTH_NET_ENV_KEY, dAuth.DAUTH_SDK_NET_DEFAULT)
1515
+
1506
1516
  if not isinstance(url, str) or len(url) < MIN_LEN:
1507
- if isinstance(DAUTH_URL, str) and len(DAUTH_URL) > 0:
1508
- url = DAUTH_URL
1509
-
1510
1517
  if DAUTH_ENV_KEY in os.environ:
1511
1518
  in_env = True
1512
1519
  url = os.environ[DAUTH_ENV_KEY]
1513
-
1520
+ else:
1521
+ if network == 'mainnet':
1522
+ url = dAuth.DAUTH_MAINNET_URL
1523
+ else:
1524
+ url = dAuth.DAUTH_TESTNET_URL
1525
+ #endif not in env
1526
+
1514
1527
  if isinstance(url, str) and len(url) > 0:
1515
1528
  if dauth_endp is None:
1516
1529
  if in_env:
@@ -3,8 +3,9 @@ from naeural_client.cli.nodes import (
3
3
  restart_node, shutdown_node,
4
4
  )
5
5
  from naeural_client.cli.oracles import get_availability
6
- from naeural_client.utils.config import show_config, reset_config, show_address
7
-
6
+ from naeural_client.utils.config import (
7
+ show_config, reset_config, show_address, get_set_network
8
+ )
8
9
 
9
10
  # Define the available commands
10
11
  CLI_COMMANDS = {
@@ -55,7 +56,15 @@ CLI_COMMANDS = {
55
56
  "addr": {
56
57
  "func": show_address, # DONE
57
58
  "description": "Show the current client address",
58
- }
59
+ },
60
+
61
+ "network": {
62
+ "func": get_set_network, # DONE
63
+ "description": "Get/Set network",
64
+ "params": {
65
+ "--new": "The network to set either 'mainnet' or 'testnet'",
66
+ }
67
+ },
59
68
  },
60
69
  "restart": {
61
70
  "func": restart_node, # TODO
@@ -1,6 +1,7 @@
1
+ import os
1
2
  from time import time
2
3
  from naeural_client.utils.config import log_with_color
3
- from naeural_client.const import SESSION_CT, COMMANDS
4
+ from naeural_client.const import SESSION_CT, COMMANDS, BASE_CT
4
5
 
5
6
 
6
7
  def _get_netstats(
@@ -62,10 +63,11 @@ def get_nodes(args):
62
63
  df = df[[c for c in df.columns if c not in FILTERED]]
63
64
 
64
65
  prefix = "Online n" if (args.online or args.peered) else "N"
66
+ network = os.environ.get(BASE_CT.dAuth.DAUTH_NET_ENV_KEY, BASE_CT.dAuth.DAUTH_SDK_NET_DEFAULT)
65
67
  if supervisor == "ERROR":
66
68
  log_with_color(f"No supervisors or no comms available in {elapsed:.1f}s. Please check your settings.", color='r')
67
69
  else:
68
- log_with_color(f"{prefix}odes reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s ({nr_supers} supervisors seen):", color='b')
70
+ log_with_color(f"<{network}> {prefix}odes reported by <{supervisor}> '{super_alias}' in {elapsed:.1f}s ({nr_supers} supervisors seen):", color='b')
69
71
  log_with_color(f"{df}")
70
72
  return
71
73
 
@@ -10,7 +10,8 @@ class BCctbase:
10
10
  ETH_SENDER= 'EE_ETH_SENDER'
11
11
 
12
12
 
13
- DAUTH_URL = 'https://dauth.ratio1.ai/get_auth_data'
13
+ DAUTH_TESTNET_URL = 'https://dauth-test.ratio1.ai/get_auth_data'
14
+ DAUTH_MAINNET_URL = 'https://dauth-main.ratio1.ai/get_auth_data'
14
15
  DAUTH_SUBKEY = 'auth'
15
16
  DAUTH_ENV_KEY = 'EE_DAUTH_URL'
16
17
  DAUTH_NONCE = 'nonce'
@@ -53,8 +54,11 @@ _DAUTH_ABI_GET_SIGNERS = [{
53
54
 
54
55
 
55
56
  class dAuth:
56
- DAUTH_TESTNET_ND_ADDR = '0x9aB4e425c7dFFC7Aa1A7a262727b0b663e047571'
57
- DAUTH_MAINNET_ND_ADDR = ''
57
+ DAUTH_TESTNET_ND_ADDR = '0xE20198EE2B76eED916A568a47cdea9681f7c79BF'
58
+ DAUTH_MAINNET_ND_ADDR = '0xE20198EE2B76eED916A568a47cdea9681f7c79BF'
59
+
60
+ DAUTH_NET_ENV_KEY = 'EE_EVM_NET'
61
+ DAUTH_SDK_NET_DEFAULT = 'testnet'
58
62
 
59
63
  DAUTH_MAINNET_RPC = 'https://base-mainnet.public.blastapi.io'
60
64
  DAUTH_TESTNET_RPC = 'https://base-sepolia.public.blastapi.io'
@@ -75,7 +79,8 @@ class dAuth:
75
79
 
76
80
  DAUTH_WHITELIST = 'whitelist'
77
81
 
78
- DAUTH_URL = DAUTH_URL
82
+ DAUTH_TESTNET_URL = DAUTH_TESTNET_URL
83
+ DAUTH_MAINNET_URL = DAUTH_MAINNET_URL
79
84
  DAUTH_SUBKEY = DAUTH_SUBKEY
80
85
  DAUTH_NONCE = DAUTH_NONCE
81
86
  DAUTH_VARS = DAUTH_VARS
@@ -2,7 +2,7 @@ import os
2
2
  from pathlib import Path
3
3
  import shutil
4
4
 
5
- from naeural_client.const.base import BCct
5
+ from naeural_client.const.base import BCct, dAuth
6
6
  from naeural_client._ver import __VER__ as version
7
7
 
8
8
 
@@ -11,15 +11,11 @@ SDK_HOME = ".naeural"
11
11
  LOCAL_PEM_PATH = "./_local_cache/_data/" + BCct.DEFAULT_PEM_FILE
12
12
 
13
13
  ENV_TEMPLATE = """
14
+ # Configuration file for the Ratio1 SDK
14
15
 
15
- EE_MQTT_HOST=r9092118.ala.eu-central-1.emqxsl.com
16
- EE_MQTT_PORT=8883
17
- EE_MQTT_USER=
18
- EE_MQTT=
16
+ EE_EVM_NET=testnet
17
+ EE_TARGET_NODE=
19
18
 
20
- EE_SECURED=true
21
-
22
- TARGET_NODE=
23
19
  """
24
20
 
25
21
  def seconds_to_short_format(seconds):
@@ -93,6 +89,33 @@ def get_user_config_file():
93
89
  """
94
90
  return get_user_folder() / CONFIG_FILE
95
91
 
92
+
93
+ def get_network():
94
+ return os.environ.get(dAuth.DAUTH_NET_ENV_KEY, dAuth.DAUTH_SDK_NET_DEFAULT)
95
+
96
+ def get_set_network(args):
97
+ net = args.new
98
+ env_network = get_network()
99
+ if net is None:
100
+ log_with_color(f"Current network: {env_network}", color='b')
101
+ else:
102
+ config_file = get_user_config_file()
103
+ # open config_file and update EE_EVM_NET
104
+ with config_file.open("r") as file:
105
+ lines = file.readlines()
106
+ with config_file.open("w") as file:
107
+ found = False
108
+ for line in lines:
109
+ if line.startswith("EE_EVM_NET"):
110
+ line = f"EE_EVM_NET={net}\n"
111
+ found = True
112
+ file.write(line)
113
+ if not found:
114
+ file.write(f"EE_EVM_NET={net}\n")
115
+ log_with_color(f"Network set to {net}", color='b')
116
+ return
117
+
118
+
96
119
  def reset_config(*larg, keep_existing=False, **kwargs):
97
120
  """
98
121
  Resets the configuration by creating a ~/.naeural folder and populating
@@ -164,8 +187,9 @@ def show_version():
164
187
 
165
188
  user_folder = get_user_folder()
166
189
 
167
- log_with_color(f"NEP SDK folder: {user_folder}", color='b')
168
- log_with_color(f"NEP SDK version: {version}", color='b')
190
+ log_with_color(f"Ratio1 selected network: {get_network()}", color='b')
191
+ log_with_color(f"SDK folder: {user_folder}", color='b')
192
+ log_with_color(f"SDK version: {version}", color='b')
169
193
  log_with_color(f"SDK Client address: {sess.get_client_address()}", color='b')
170
194
  return
171
195
 
@@ -181,6 +205,10 @@ def show_config(args):
181
205
  log_with_color(f"Current configuration ({config_file}):\n{file.read()}", color='d')
182
206
  else:
183
207
  log_with_color(f"No configuration found at {config_file}. Please run `reset_config` first.", color="r")
208
+ log_with_color("Current environment variables:", color='b')
209
+ for k in os.environ:
210
+ if k.startswith("EE_"):
211
+ log_with_color(f"{k}={os.environ[k]}", color='b')
184
212
  return
185
213
 
186
214
 
@@ -190,7 +218,7 @@ def load_user_defined_config(verbose=False):
190
218
  """
191
219
  config_file = get_user_config_file()
192
220
  result = False
193
-
221
+ loaded_keys = []
194
222
  if config_file.exists():
195
223
  with config_file.open("r") as file:
196
224
  for line in file:
@@ -202,8 +230,9 @@ def load_user_defined_config(verbose=False):
202
230
  if value != "":
203
231
  result = True
204
232
  os.environ[key.strip()] = value
233
+ loaded_keys.append(key.strip())
205
234
  if verbose:
206
- log_with_color(f"Configuration from {config_file} has been loaded into the environment.", color='b')
235
+ log_with_color(f"{config_file} loaded into the env: {loaded_keys}", color='b')
207
236
  else:
208
237
  if verbose:
209
238
  log_with_color(f"No configuration file found at {config_file}. Please run `reset_config` first.", color="r")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.6.41
3
+ Version: 2.7.1
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=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=jRx8rmVlh1pdQJHh66Tj_JEqEPJMYnWRsbTGdwt9cEA,331
2
+ naeural_client/_ver.py,sha256=9vyNSWt4S6kU_mE1kzVtnvSPeM4KKDk55WEx5yLCQ-c,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=zSm9tw3WxdkvMiD5YXR7_B86E6vt2F4FCajKEah3JMc,105845
7
+ naeural_client/base/generic_session.py,sha256=3Z7BGi1g5zIXDAUk-PCKsXVhQKaJldL9id2SDedbSIU,105872
8
8
  naeural_client/base/instance.py,sha256=kcZJmjLBtx8Bjj_ysIOx1JmLA-qSpG7E28j5rq6IYus,20444
9
9
  naeural_client/base/pipeline.py,sha256=EvESG5UH5GwyAZbJWJk1irTzGYBuOUjl-8KjkCdgLVI,58574
10
10
  naeural_client/base/plugin_template.py,sha256=7YAFaND2iXoZLgtunjYkFf_TBGieFr3VdNLO3vCqzmM,138795
@@ -14,15 +14,15 @@ naeural_client/base/webapp_pipeline.py,sha256=ZNGqZ36DY076XVDfGu2Q61kCt3kxIJ4Mi4
14
14
  naeural_client/base/payload/__init__.py,sha256=y8fBI8tG2ObNfaXFWjyWZXwu878FRYj_I8GIbHT4GKE,29
15
15
  naeural_client/base/payload/payload.py,sha256=x-au7l67Z_vfn_4R2C_pjZCaFuUVXHngJiGOfIAYVdE,2690
16
16
  naeural_client/bc/__init__.py,sha256=FQj23D1PrY06NUOARiKQi4cdj0-VxnoYgYDEht8lpr8,158
17
- naeural_client/bc/base.py,sha256=rrzhpcymcQBaxfo-fLgG8a5DqkdN_W75Ud9naEHvzy0,44759
17
+ naeural_client/bc/base.py,sha256=wfNdwr-dWPftRkq0YdaBZ1xhzdhnz220bpFqqH8iVQM,45152
18
18
  naeural_client/bc/chain.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  naeural_client/bc/ec.py,sha256=-HPfKpYAqy_eZpiJf3gWR2L4ZDDP7fZY2uwdNYYmS80,23868
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
23
  naeural_client/cli/cli.py,sha256=EC7-ehOMQJ_Dq7R9TTrajpvQWwdalAOgb1JAeBGHF50,3830
24
- naeural_client/cli/cli_commands.py,sha256=Gfims_TqaBi2QWM-6yxd_B_CETF8mmt7oEDPTg59lcI,2821
25
- naeural_client/cli/nodes.py,sha256=QXSniYy3Phr6buoVV-HUDRYuF5YQDUgf6nT6EzDyMJw,4909
24
+ naeural_client/cli/cli_commands.py,sha256=Ztm1qXUN58OZb-CO6TzWlwCgZyzCxK5C1s49lz6fNmQ,3088
25
+ naeural_client/cli/nodes.py,sha256=A-MqGjI_ufZ7SnlVyMOzlqWQASRvKvF6cz9AGxlbYx4,5037
26
26
  naeural_client/cli/oracles.py,sha256=Y_PzHshfSERS_Utjjtw5d_BsQRdGr6P4L6uW8yTdA0M,4809
27
27
  naeural_client/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
28
28
  naeural_client/code_cheker/base.py,sha256=lT5DRIFO5rqzsMNCmdMRfkAeevmezozehyfgmhnKpuI,19074
@@ -33,7 +33,7 @@ naeural_client/comm/mqtt_wrapper.py,sha256=Ig3bFZkCbWd4y_Whn2PPa91Z3aLgNbNPau6Tn
33
33
  naeural_client/const/README.md,sha256=6OHesr-f5NBuuJGryEoi_TCu2XdlhfQYlDKx_IJoXeg,177
34
34
  naeural_client/const/__init__.py,sha256=MM6Zib6i7M2qWcMkLtLx14zqU-lE-u2uPHjNvbh2jAM,478
35
35
  naeural_client/const/apps.py,sha256=ePBiJXLuPfFOKuw-LJrT9OWbaodU7QApfDurIPNDoB4,655
36
- naeural_client/const/base.py,sha256=4VNZdm3Bzigure1SqkZ94buEdwVnQhb5cI3KBYlJgFs,6260
36
+ naeural_client/const/base.py,sha256=g3II1Ys-1sjr1OG-sDJyRCV3F48VnxKQc7zTBPn-7FE,6510
37
37
  naeural_client/const/comms.py,sha256=La6JXWHexH8CfcBCKyT4fCIoeaoZlcm7KtZ57ab4ZgU,2201
38
38
  naeural_client/const/environment.py,sha256=iytmTDgbOjvORPwHQmc0K0r-xJx7dnnzNnqAJJiFCDA,870
39
39
  naeural_client/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
@@ -80,11 +80,11 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
80
80
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
81
81
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
82
82
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
83
- naeural_client/utils/config.py,sha256=Ub5sw3NG6wskAF5C4s0WU0rzXHVLy70ZTRU0W8HUGTM,6403
83
+ naeural_client/utils/config.py,sha256=GzduH5_ZFN39RBdpICDKhx2ZqXen5fF-JJ0RoEcF2wQ,7401
84
84
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
85
85
  naeural_client/utils/oracle_sync/oracle_tester.py,sha256=GmZwu2JM9_UB2K-4rKB3o0RgWLqM-7Im6HwBnQLXmHI,25312
86
- naeural_client-2.6.41.dist-info/METADATA,sha256=rGgli3LSZXZyouXMJAQajOd_TIRRNC8-I3Z9bVB-EA0,12354
87
- naeural_client-2.6.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
88
- naeural_client-2.6.41.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
89
- naeural_client-2.6.41.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
90
- naeural_client-2.6.41.dist-info/RECORD,,
86
+ naeural_client-2.7.1.dist-info/METADATA,sha256=ZiN9iutGlO_Sf-k5xFy1TCT-86FkMo-M8yBwrbedAyY,12353
87
+ naeural_client-2.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
88
+ naeural_client-2.7.1.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
89
+ naeural_client-2.7.1.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
90
+ naeural_client-2.7.1.dist-info/RECORD,,