ratio1 3.4.39__py3-none-any.whl → 3.4.40__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.
ratio1/_ver.py CHANGED
@@ -1,4 +1,4 @@
1
- __VER__ = "3.4.39"
1
+ __VER__ = "3.4.40"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -2696,7 +2696,7 @@ class GenericSession(BaseDecentrAIObject):
2696
2696
  node = self.__get_node_address(node)
2697
2697
  return node in self._dct_online_nodes_pipelines
2698
2698
 
2699
- def is_peered(self, node):
2699
+ def is_peered(self, node, return_full_address=False):
2700
2700
  """
2701
2701
  Public method for checking if a node is peered with the current session.
2702
2702
  Parameters
@@ -2709,8 +2709,10 @@ class GenericSession(BaseDecentrAIObject):
2709
2709
  bool
2710
2710
  True if the node is peered, False otherwise.
2711
2711
  """
2712
- node = self.__get_node_address(node)
2713
- return self._dct_can_send_to_node.get(node, False)
2712
+ node_addr = self.__get_node_address(node)
2713
+ if return_full_address:
2714
+ return self._dct_can_send_to_node.get(node_addr, False), node_addr
2715
+ return self._dct_can_send_to_node.get(node_addr, False)
2714
2716
 
2715
2717
  def get_last_seen_time(self, node, *, default_value=0):
2716
2718
  """
ratio1/cli/nodes.py CHANGED
@@ -209,52 +209,39 @@ def get_apps(args):
209
209
  return
210
210
 
211
211
  def _send_command_to_node(args, command, ignore_not_found=False):
212
+ from ratio1 import Session
213
+
212
214
  node = args.node
213
215
  silent = not args.verbose
214
216
  ignore_peering = args.ignore_peering
215
217
 
216
218
  t1 = time()
217
- df, _, _, _, _, sess = _get_netstats(
218
- silent=silent, online_only=True, return_session=True, all_info=True,
219
- wait_for_node=node
220
- )
221
-
222
- peered = None
223
- selection = (df.Alias == node) | (df.Address == node)
224
- if 'ETH Address' in df.columns:
225
- selection = selection | (df['ETH Address'] == node)
226
- found = selection.any()
227
- node_addr = None
228
- alias = None
229
- df_found = df[selection]
230
- if found:
231
- alias = df_found.Alias.values[0]
232
- peered = df_found.Peered.values[0]
233
- node_addr = df_found.Address.values[0]
234
- log_with_color(f"{df_found}")
235
- else:
236
- log_with_color("Node '{}' <{}> not found in network (total {} nodes, {} peered).".format(
237
- node, node_addr, df.shape[0], df.Peered.sum()), color='r'
238
- )
239
- node_addr = node
219
+ sess = Session(silent=silent)
220
+
221
+ peered, node_addr = sess.is_peered(node, return_full_address=True)
222
+ found = False
240
223
 
241
- if not peered and not ignore_peering:
242
- log_with_color(f"Node '{node}' <{node_addr}> not peered, exiting...", color='r')
243
- return
224
+ if not ignore_peering:
225
+ found = sess.wait_for_node(node_addr, timeout=30)
226
+ sess.P(f"Node {node_addr} is online.")
244
227
 
228
+ # Display peering status.
245
229
  if not peered:
230
+ if not ignore_peering:
231
+ log_with_color(f"Node <{node_addr}> is not peered. Exiting...", color='r')
232
+ return
233
+
246
234
  if found:
247
235
  log_with_color(f"Node '{node}' <{node_addr}> is not peered.", color='r')
248
236
  else:
249
237
  log_with_color(f"Node '{node}' <{node_addr}> may not accept this command.", color='r')
250
238
 
251
- # TODO: currently this is based on node alias, but we should be based on node address
252
- # and maybe even node alias
253
- if (found and peered) or ignore_not_found:
254
- if found and peered:
255
- log_with_color(f"Sending '{command}' to node '{alias}' <{node_addr}>", color='b')
256
- else:
257
- log_with_color(f"Sending blind '{command}' to node '{alias}' <{node_addr}>", color='b')
239
+ if found and peered:
240
+ log_with_color(f"Sending '{command}' to node <{node_addr}>", color='b')
241
+ else:
242
+ log_with_color(f"Sending blind '{command}' to node <{node_addr}>", color='b')
243
+
244
+ if (found and peered) or ignore_not_found or ignore_peering:
258
245
  if command == COMMANDS.RESTART:
259
246
  sess._send_command_restart_node(node_addr)
260
247
  elif command == COMMANDS.STOP:
@@ -262,7 +249,12 @@ def _send_command_to_node(args, command, ignore_not_found=False):
262
249
  else:
263
250
  log_with_color(f"Command '{command}' not supported.", color='r')
264
251
  return
265
- elapsed = time() - t1
252
+
253
+ sess.close()
254
+ log_with_color(f"Command successfully sent.")
255
+ elapsed = time() - t1
256
+ if not silent:
257
+ log_with_color(f"Command '{command}' seinging took {elapsed}s.", color='b')
266
258
  return
267
259
 
268
260
  def restart_node(args):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ratio1
3
- Version: 3.4.39
3
+ Version: 3.4.40
4
4
  Summary: `ratio1` or Ration1 SDK is the Python SDK required for client app development for the Ratio1 ecosystem
5
5
  Project-URL: Homepage, https://github.com/Ratio1/ratio1_sdk
6
6
  Project-URL: Bug Tracker, https://github.com/Ratio1/ratio1_sdk/issues
@@ -1,10 +1,10 @@
1
1
  ratio1/__init__.py,sha256=YimqgDbjLuywsf8zCWE0EaUXH4MBUrqLxt0TDV558hQ,632
2
- ratio1/_ver.py,sha256=ABDRSXrsWdo9F3E_13s2gVLWdHtO1ykuvzBGeSroSHg,331
2
+ ratio1/_ver.py,sha256=zlrigFbgf6eJq1eow1kVyGQ8QOgt1xZpjWDhUjft6tY,331
3
3
  ratio1/base_decentra_object.py,sha256=iXvAAf6wPnGWzeeiRfwLojVoan-m1e_VsyPzjUQuENo,4492
4
4
  ratio1/plugins_manager_mixin.py,sha256=X1JdGLDz0gN1rPnTN_5mJXR8JmqoBFQISJXmPR9yvCo,11106
5
5
  ratio1/base/__init__.py,sha256=hACh83_cIv7-PwYMM3bQm2IBmNqiHw-3PAfDfAEKz9A,259
6
6
  ratio1/base/distributed_custom_code_presets.py,sha256=cvz5R88P6Z5V61Ce1vHVVh8bOkgXd6gve_vdESDNAsg,2544
7
- ratio1/base/generic_session.py,sha256=CaDFbcAd7oefVCQFKYA0r-H5FU6FTxG3By-eQDvt1qU,185384
7
+ ratio1/base/generic_session.py,sha256=LsZaQTg9IyG0jXMmFhXQqxOCGCPvAPXZoVvom8cWfCc,185526
8
8
  ratio1/base/instance.py,sha256=oQvwzzRvir7851wyhDx_BwN6y_VgsNWwYo53vN33QI4,21914
9
9
  ratio1/base/pipeline.py,sha256=szoHrk1qBdY6NKPUk3tUTsJx3XzYp5C2GTOlzRiQi48,62489
10
10
  ratio1/base/plugin_template.py,sha256=Gs438cSkhvxPujE4CRH_32pcuZaVwI9kia8E4VDRpSU,138794
@@ -26,7 +26,7 @@ ratio1/certs/s624dbd4.ala.us-east-1.emqxsl.com.crt,sha256=y-6io0tseyx9-a4Pmde1z1
26
26
  ratio1/cli/README.md,sha256=YsT23YcZBRyTKReNZPxD762YqstSWKWz4iZe_UJELPc,73
27
27
  ratio1/cli/cli.py,sha256=D8UCtdTQKi1IqB_PAi3k2FfaM-rnfxmlrOzM4OJBOsA,4352
28
28
  ratio1/cli/cli_commands.py,sha256=aoPnASJ3uPHWqABLCL-E6J3U0npK7kxX8U07s_aR9qA,6290
29
- ratio1/cli/nodes.py,sha256=0QjAbAhn_KrrjiGUXQ0GhnxCM-Zvxhx32FNcQd9hhHI,14237
29
+ ratio1/cli/nodes.py,sha256=EZxjw8G8Kj0PPMHtUJoefm4QootrU50GHlpaJOiHxJo,13787
30
30
  ratio1/cli/oracles.py,sha256=HTQAKEwe-j0E00JKKPCH1GXjelyy0IAjzLZIx8qtimU,11141
31
31
  ratio1/cli/package_update.py,sha256=uRMPW5XV3fBdB_eZfoQDA1SKnJzTJvyfpRJA6T3ZZlQ,4000
32
32
  ratio1/code_cheker/__init__.py,sha256=pwkdeZGVL16ZA4Qf2mRahEhoOvKhL7FyuQbMFLr1E5M,33
@@ -103,8 +103,8 @@ ratio1/utils/comm_utils.py,sha256=4cS9llRr_pK_3rNgDcRMCQwYPO0kcNU7AdWy_LtMyCY,10
103
103
  ratio1/utils/config.py,sha256=IMXAN9bpHePKEuTFGRRqFJXz_vBa-wi7s9gLhFEheRY,9953
104
104
  ratio1/utils/dotenv.py,sha256=_AgSo35n7EnQv5yDyu7C7i0kHragLJoCGydHjvOkrYY,2008
105
105
  ratio1/utils/oracle_sync/oracle_tester.py,sha256=aJOPcZhtbw1XPqsFG4qYpfv2Taj5-qRXbwJzrPyeXDE,27465
106
- ratio1-3.4.39.dist-info/METADATA,sha256=Ox5xn1ySF8iu38F1QY5yDslBg4rkNNpQ6k2uolDFD5I,12248
107
- ratio1-3.4.39.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
- ratio1-3.4.39.dist-info/entry_points.txt,sha256=DR_olREzU1egwmgek3s4GfQslBi-KR7lXsd4ap0TFxE,46
109
- ratio1-3.4.39.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
110
- ratio1-3.4.39.dist-info/RECORD,,
106
+ ratio1-3.4.40.dist-info/METADATA,sha256=oOOOjfuuQspNmWwiwIt2Gz4hRgES9vpgmcBS3ldtd_o,12248
107
+ ratio1-3.4.40.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
108
+ ratio1-3.4.40.dist-info/entry_points.txt,sha256=DR_olREzU1egwmgek3s4GfQslBi-KR7lXsd4ap0TFxE,46
109
+ ratio1-3.4.40.dist-info/licenses/LICENSE,sha256=cvOsJVslde4oIaTCadabXnPqZmzcBO2f2zwXZRmJEbE,11311
110
+ ratio1-3.4.40.dist-info/RECORD,,