naeural-client 2.7.29__py3-none-any.whl → 2.7.31__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.7.29"
1
+ __VER__ = "2.7.31"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -8,38 +8,42 @@ class EvmNetData:
8
8
  EE_EPOCH_INTERVAL_SECONDS_KEY = 'EE_EPOCH_INTERVAL_SECONDS'
9
9
 
10
10
  EE_SUPERVISOR_MIN_AVAIL_PRC_KEY = 'EE_SUPERVISOR_MIN_AVAIL_PRC'
11
-
11
+
12
+ EE_ORACLE_API_URL_KEY = 'EE_ORACLE_API_URL'
12
13
 
13
14
  EVM_NET_DATA = {
14
15
  'mainnet': {
15
- EvmNetData.DAUTH_URL_KEY : "https://dauth-main.ratio1.ai/get_auth_data",
16
+ EvmNetData.DAUTH_URL_KEY : "https://dauth.ratio1.ai/get_auth_data",
16
17
  EvmNetData.DAUTH_ND_ADDR_KEY : "0xE20198EE2B76eED916A568a47cdea9681f7c79BF",
17
18
  EvmNetData.DAUTH_RPC_KEY : "https://base-mainnet.public.blastapi.io",
18
19
  EvmNetData.EE_GENESIS_EPOCH_DATE_KEY : "2025-02-05 16:00:00",
19
20
  EvmNetData.EE_EPOCH_INTERVALS_KEY : 24,
20
21
  EvmNetData.EE_EPOCH_INTERVAL_SECONDS_KEY : 3600,
21
22
  EvmNetData.EE_SUPERVISOR_MIN_AVAIL_PRC_KEY : 0.98,
23
+ EvmNetData.EE_ORACLE_API_URL_KEY : "https://oracle.ratio1.ai",
22
24
  },
23
25
 
24
26
  'testnet': {
25
- EvmNetData.DAUTH_URL_KEY : "https://dauth-test.ratio1.ai/get_auth_data",
27
+ EvmNetData.DAUTH_URL_KEY : "https://testnet-dauth.ratio1.ai/get_auth_data",
26
28
  EvmNetData.DAUTH_ND_ADDR_KEY : "0xE20198EE2B76eED916A568a47cdea9681f7c79BF",
27
29
  EvmNetData.DAUTH_RPC_KEY : "https://base-sepolia.public.blastapi.io",
28
30
  EvmNetData.EE_GENESIS_EPOCH_DATE_KEY : "2025-02-05 16:00:00",
29
31
  EvmNetData.EE_EPOCH_INTERVALS_KEY : 24,
30
32
  EvmNetData.EE_EPOCH_INTERVAL_SECONDS_KEY : 3600,
31
33
  EvmNetData.EE_SUPERVISOR_MIN_AVAIL_PRC_KEY : 0.6,
34
+ EvmNetData.EE_ORACLE_API_URL_KEY : "https://testnet-oracle.ratio1.ai",
32
35
  },
33
36
 
34
37
 
35
38
  'devnet' : {
36
- EvmNetData.DAUTH_URL_KEY : "https://dauth-devnet.ratio1.ngrok.app/get_auth_data",
39
+ EvmNetData.DAUTH_URL_KEY : "https://devnet-dauth.ratio1.ai/get_auth_data",
37
40
  EvmNetData.DAUTH_ND_ADDR_KEY : "0x9f49fc29366F1C8285d42e7E82cA0bb668B32CeA",
38
41
  EvmNetData.DAUTH_RPC_KEY : "https://base-sepolia.public.blastapi.io",
39
42
  EvmNetData.EE_GENESIS_EPOCH_DATE_KEY : "2025-02-12 16:00:00",
40
43
  EvmNetData.EE_EPOCH_INTERVALS_KEY : 1,
41
44
  EvmNetData.EE_EPOCH_INTERVAL_SECONDS_KEY : 3600,
42
45
  EvmNetData.EE_SUPERVISOR_MIN_AVAIL_PRC_KEY : 0.6,
46
+ EvmNetData.EE_ORACLE_API_URL_KEY : "https://devnet-oracle.ratio1.ai",
43
47
  },
44
48
 
45
49
  }
@@ -1122,7 +1122,7 @@ class BaseLogger(object):
1122
1122
  def _maybe_migrate_folder(self):
1123
1123
  user_base_folder = BaseLogger.get_user_folder(as_str=True, include_sdk_home=True)
1124
1124
  if user_base_folder in self._base_folder:
1125
- BaseLogger.maybe_migrate_user_folder(verbose=True)
1125
+ BaseLogger.maybe_migrate_user_folder()
1126
1126
  return
1127
1127
 
1128
1128
  def _configure_data_and_dirs(self, config_file, config_file_encoding=None):
@@ -327,7 +327,7 @@ def maybe_init_config():
327
327
  """
328
328
  config_file = get_user_config_file()
329
329
  if not config_file.exists():
330
- BaseLogger.maybe_migrate_user_folder(verbose=True)
330
+ BaseLogger.maybe_migrate_user_folder()
331
331
  if not config_file.exists():
332
332
  log_with_color(f"No configuration file found at {config_file}. Initializing configuration...", color="y")
333
333
  reset_config(keep_existing=True)
@@ -11,11 +11,10 @@ from collections import defaultdict
11
11
  from naeural_client import Logger
12
12
  from naeural_client.bc import DefaultBlockEngine
13
13
  from naeural_client.utils.config import log_with_color, get_user_folder
14
-
14
+ from naeural_client.const.evm_net import EvmNetData
15
15
 
16
16
 
17
17
  class OracleTesterConstants:
18
- BASE_URL = "https://naeural-oracle.ngrok.app"
19
18
  TEST_ENDPOINT = "/node_epochs_range"
20
19
  CURRENT_EPOCH_ENDPOINT = "/current_epoch"
21
20
  ACTIVE_NODES_ENDPOINT = "/active_nodes_list"
@@ -38,7 +37,6 @@ class OracleTester:
38
37
  ):
39
38
  self.bc = bce
40
39
  self.log = log
41
- self.BASE_URL = ct.BASE_URL
42
40
  self.TEST_ENDPOINT = ct.TEST_ENDPOINT
43
41
  self.CURRENT_EPOCH_ENDPOINT = ct.CURRENT_EPOCH_ENDPOINT
44
42
  self.ACTIVE_NODES_ENDPOINT = ct.ACTIVE_NODES_ENDPOINT
@@ -56,6 +54,27 @@ class OracleTester:
56
54
 
57
55
  """UTILS"""
58
56
  if True:
57
+ def get_base_url(self, network=None):
58
+ """
59
+ Get the base URL for the oracle API server.
60
+ Parameters
61
+ ----------
62
+ network : str or None
63
+ The network for which to get the base URL. Default None.
64
+ If None, the network from the user config will be used.
65
+
66
+ Returns
67
+ -------
68
+ str
69
+ The base URL for the oracle API server.
70
+ """
71
+ network = network or self.bc.evm_network
72
+ res = self.bc.get_network_data(network=network).get(EvmNetData.EE_ORACLE_API_URL_KEY)
73
+ if res is None:
74
+ msg_end = f" for the network: {network}" if network is not None else ""
75
+ raise ValueError(f"Failed to get the base URL{msg_end}.")
76
+ return res
77
+
59
78
  def maybe_register_node(self, node_addr: str, eth_address: str, alias: str = None):
60
79
  if node_addr is None:
61
80
  return
@@ -239,7 +258,7 @@ class OracleTester:
239
258
  return stats_dict
240
259
  """END RESPONSE HANDLING"""
241
260
 
242
- def gather(self, nodes, request_kwargs=None, debug=False, rounds=None):
261
+ def gather(self, nodes, request_kwargs=None, debug=False, rounds=None, network=None):
243
262
  """
244
263
  Gather data from the oracle server for the given nodes.
245
264
 
@@ -253,6 +272,12 @@ class OracleTester:
253
272
  The request kwargs to be used for the request. Default None.
254
273
  debug : bool
255
274
  Whether to enable debug mode or not. If enabled the function will exit after one request round.
275
+ rounds : int
276
+ The number of rounds to be executed. Default None. If None, self.max_request_rounds will be used.
277
+ network : str
278
+ The network for which to gather data. Default None.
279
+ If None, the network from the user config will be used.
280
+ In case the network is not found in the user config, the testnet will be used.
256
281
 
257
282
  Returns
258
283
  -------
@@ -266,7 +291,7 @@ class OracleTester:
266
291
  while not self.done(rounds):
267
292
  try:
268
293
  self.P(f'Starting request round {self.request_rounds + 1} for {len(nodes)} nodes...')
269
- current_url = self.BASE_URL + self.TEST_ENDPOINT
294
+ current_url = self.get_base_url(network=network) + self.TEST_ENDPOINT
270
295
  # TODO: maybe shuffle the nodes list in order to avoid
271
296
  # the same order of requests in each round
272
297
  # relevant if the number of nodes is divisible by the number of oracles.
@@ -309,7 +334,7 @@ class OracleTester:
309
334
  self.P(f'Finished gathering data for {len(nodes)} nodes and {self.max_request_rounds}.')
310
335
  return responses, stats_dict
311
336
 
312
- def gather_and_compare(self, nodes, request_kwargs=None, debug=False, rounds=None):
337
+ def gather_and_compare(self, nodes, request_kwargs=None, debug=False, rounds=None, network=None):
313
338
  """
314
339
  Gather data from the oracle server for the given nodes and compare the results between oracles.
315
340
 
@@ -323,6 +348,12 @@ class OracleTester:
323
348
  The request kwargs to be used for the request. Default None.
324
349
  debug : bool
325
350
  Whether to enable debug mode or not. If enabled the function will exit after one request round.
351
+ rounds : int
352
+ The number of rounds to be executed. Default None. If None, self.max_request_rounds will be used.
353
+ network : str
354
+ The network for which to gather data. Default None.
355
+ If None, the network from the user config will be used.
356
+ In case the network is not found in the user config, the testnet will be used.
326
357
 
327
358
  Returns
328
359
  -------
@@ -333,7 +364,8 @@ class OracleTester:
333
364
  nodes=nodes,
334
365
  request_kwargs=request_kwargs,
335
366
  debug=debug,
336
- rounds=rounds
367
+ rounds=rounds,
368
+ network=network
337
369
  )
338
370
  # Statistics for each node of each epoch
339
371
  epochs_nodes_stats = {}
@@ -381,15 +413,15 @@ class OracleTester:
381
413
 
382
414
  return responses, stats_dict
383
415
 
384
- def get_current_epoch(self):
385
- epoch_url = self.BASE_URL + self.CURRENT_EPOCH_ENDPOINT
416
+ def get_current_epoch(self, network=None):
417
+ epoch_url = self.get_base_url(network=network) + self.CURRENT_EPOCH_ENDPOINT
386
418
  response = self.make_request(epoch_url)
387
419
  if response:
388
420
  return response.get("result", {}).get("current_epoch", 1)
389
421
  return None
390
422
 
391
- def get_active_nodes(self):
392
- active_nodes_url = self.BASE_URL + self.ACTIVE_NODES_ENDPOINT
423
+ def get_active_nodes(self, network=None):
424
+ active_nodes_url = self.get_base_url(network=network) + self.ACTIVE_NODES_ENDPOINT
393
425
  response = self.make_request(active_nodes_url)
394
426
  result = []
395
427
  if response:
@@ -589,10 +621,15 @@ def oracle_tester_init(silent=True, **kwargs):
589
621
  return tester
590
622
 
591
623
  def test_commands():
592
- tester = oracle_tester_init()
593
- start = 78
594
- end = 85
595
- node_eth_addr = "<node_eth_address>"
624
+ from naeural_client.utils.config import load_user_defined_config
625
+ load_user_defined_config()
626
+ tester = oracle_tester_init(max_requests_rounds=30)
627
+ start = 10
628
+ end = 10
629
+ # node_eth_addr = "0x7C07758C23DF14c2fF4b016F0ad58F2D4aF329a7" # r1s-ssj-1
630
+ # node_eth_addr = "0xdc4fDFd5B86aeA7BaB17d4742B7c39A2728Ff59B" # r1s-02
631
+ # node_eth_addr = "0x93B04EF1152D81A0847C2272860a8a5C70280E14" # tr1s-aid02
632
+ node_eth_addr = '0x37379B80c7657620E5631832c4437B51D67A88cB' # dr1s-db-1
596
633
 
597
634
  # Single round
598
635
  tester.P(f'Test single round: Epochs {start} to {end}', show=True)
@@ -601,12 +638,12 @@ def test_commands():
601
638
 
602
639
  # Multiple rounds
603
640
  tester.P(f'Test multiple rounds: Epochs {start} to {end}', show=True)
604
- res = tester.execute_command(node_eth_addr=node_eth_addr, start=start, end=end, rounds=5)
641
+ res = tester.execute_command(node_eth_addr=node_eth_addr, start=start, end=end, rounds=3)
605
642
  handle_command_results(res)
606
643
 
607
644
  # Debug mode
608
645
  tester.P(f'Test debug mode: Epochs {start} to {end}', show=True)
609
- res = tester.execute_command(node_eth_addr=node_eth_addr, start=80, end=85, debug=True)
646
+ res = tester.execute_command(node_eth_addr=node_eth_addr, start=5, end=7, debug=True)
610
647
  handle_command_results(res)
611
648
  return
612
649
 
@@ -694,8 +731,8 @@ def oracle_test(N=10):
694
731
 
695
732
  # Main loop
696
733
  def main():
697
- TEST_COMMANDS = False
698
- TEST_ORACLE = True
734
+ TEST_COMMANDS = True
735
+ TEST_ORACLE = False
699
736
  if TEST_COMMANDS:
700
737
  test_commands()
701
738
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: naeural_client
3
- Version: 2.7.29
3
+ Version: 2.7.31
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,5 +1,5 @@
1
1
  naeural_client/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- naeural_client/_ver.py,sha256=JqBpFIjrfwZRS_X2fLTG2ivMFcGrMcEOLgQ2jSW3iOY,331
2
+ naeural_client/_ver.py,sha256=txvzfbhMSo8ZJdttNBeVblWMbw5beX2aZ0Rf_eZ4JtA,331
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
@@ -38,7 +38,7 @@ naeural_client/const/apps.py,sha256=ePBiJXLuPfFOKuw-LJrT9OWbaodU7QApfDurIPNDoB4,
38
38
  naeural_client/const/base.py,sha256=zfJyGGdrNz_OA5i_6cQxH2lEeJ4PO3092NrwM_gZ_U8,5670
39
39
  naeural_client/const/comms.py,sha256=La6JXWHexH8CfcBCKyT4fCIoeaoZlcm7KtZ57ab4ZgU,2201
40
40
  naeural_client/const/environment.py,sha256=RpdDhDgB8NgRoFTk28eODigf9y0WcT9lul6mBOD029w,879
41
- naeural_client/const/evm_net.py,sha256=mOSvsJnir1v_BrmKS51xIy9ddlZnQwlXWenzGXmXMOE,2606
41
+ naeural_client/const/evm_net.py,sha256=IEX8t7OcDwONfYcqooZjmgsbFeWy6VynKHK-7nZD0KM,2891
42
42
  naeural_client/const/formatter.py,sha256=AW3bWlqf39uaqV4BBUuW95qKYfF2OkkU4f9hy3kSVhM,200
43
43
  naeural_client/const/heartbeat.py,sha256=xHZBX_NzHTklwA2_AEKR0SGdlbavMT4nirqjQg8WlTU,2550
44
44
  naeural_client/const/misc.py,sha256=VDCwwpf5bl9ltx9rzT2WPVP8B3mZFRufU1tSS5MO240,413
@@ -61,7 +61,7 @@ naeural_client/io_formatter/default/a_dummy.py,sha256=qr9eUizQ-NN5jdXVzkaZKMaf9K
61
61
  naeural_client/io_formatter/default/aixp1.py,sha256=MX0TeUR4APA-qN3vUC6uzcz8Pssz5lgrQWo7td5Ri1A,3052
62
62
  naeural_client/io_formatter/default/default.py,sha256=gEy78cP2D5s0y8vQh4aHuxqz7D10gGfuiKF311QhrpE,494
63
63
  naeural_client/logging/__init__.py,sha256=b79X45VC6c37u32flKB2GAK9f-RR0ocwP0JDCy0t7QQ,33
64
- naeural_client/logging/base_logger.py,sha256=c-ZSMHc_eO84MKrLOJcClxvhQydFD8W0LoWe5_hu2ag,69611
64
+ naeural_client/logging/base_logger.py,sha256=qqqMX30Vmh5Dz8YYaeL_ainQPTP5FsX1Y4QMbsIG5Rg,69599
65
65
  naeural_client/logging/small_logger.py,sha256=m12hCb_H4XifJYYfgCAOUDkcXm-h4pSODnFf277OFVI,2937
66
66
  naeural_client/logging/logger_mixins/__init__.py,sha256=yQO7umlRvz63FeWpi-F9GRmC_MOHcNW6R6pwvZZBy3A,600
67
67
  naeural_client/logging/logger_mixins/class_instance_mixin.py,sha256=xUXE2VZgmrlrSrvw0f6GF1jlTnVLeVkIiG0bhlBfq3o,2741
@@ -83,11 +83,11 @@ naeural_client/logging/tzlocal/win32.py,sha256=zBoj0vFVrGhnCm_f7xmYzGym4-fV-4Ij2
83
83
  naeural_client/logging/tzlocal/windows_tz.py,sha256=Sv9okktjZJfRGGUOOppsvQuX_eXyXUxkSKCAFmWT9Hw,34203
84
84
  naeural_client/utils/__init__.py,sha256=mAnke3-MeRzz3nhQvhuHqLnpaaCSmDxicd7Ck9uwpmI,77
85
85
  naeural_client/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,1072
86
- naeural_client/utils/config.py,sha256=IG7-rRYBWCqCiI2kDesFmY8gld0Ku9xWgzNPE1rwVcA,10352
86
+ naeural_client/utils/config.py,sha256=lAbWe3UMi40BOdsAIZIb-fYtb4LwG3MIYg0EOA1ITr8,10340
87
87
  naeural_client/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
88
- naeural_client/utils/oracle_sync/oracle_tester.py,sha256=GmZwu2JM9_UB2K-4rKB3o0RgWLqM-7Im6HwBnQLXmHI,25312
89
- naeural_client-2.7.29.dist-info/METADATA,sha256=rWf_TRBs9LncFBWUHz9UAWuou8d5U3Y9vWXiXPN0410,12354
90
- naeural_client-2.7.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
91
- naeural_client-2.7.29.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
92
- naeural_client-2.7.29.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
93
- naeural_client-2.7.29.dist-info/RECORD,,
88
+ naeural_client/utils/oracle_sync/oracle_tester.py,sha256=X-923ccjkr6_kzbbiuAAcWSIhMtBDOH2VURjTh55apQ,27235
89
+ naeural_client-2.7.31.dist-info/METADATA,sha256=0GqYz-TDWNENqA9JIZesUQajhYoUFL39urhid0YxPlo,12354
90
+ naeural_client-2.7.31.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
91
+ naeural_client-2.7.31.dist-info/entry_points.txt,sha256=CTua17GUrRa4aXeafezGC9TiWKGKQzwTjQmB2jyj22g,91
92
+ naeural_client-2.7.31.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
93
+ naeural_client-2.7.31.dist-info/RECORD,,