Skip to content

Commit

Permalink
Remove Py-Substrate-Interface class entirely (#47)
Browse files Browse the repository at this point in the history
Remove py-substrate-interface class, use bt-decoder for arbitrary SCALE decoding

---------

Co-authored-by: ibraheem-opentensor <ibraheem@opentensor.dev>
  • Loading branch information
thewhaleking and ibraheem-opentensor authored Sep 16, 2024
1 parent a52b59e commit ccfb3a5
Show file tree
Hide file tree
Showing 16 changed files with 1,668 additions and 435 deletions.
41 changes: 24 additions & 17 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import curses
import os.path
import re
import sys
from pathlib import Path
from typing import Coroutine, Optional

Expand Down Expand Up @@ -141,10 +142,10 @@ class Options:
prompt=True,
)
weights = typer.Option(
[],
"--weights",
"-w",
help="Corresponding weights for the specified UIDs, e.g. `-w 0.2 -w 0.4 -w 0.1 ...",
[],
"--weights",
"-w",
help="Corresponding weights for the specified UIDs, e.g. `-w 0.2 -w 0.4 -w 0.1 ...",
)
reuse_last = typer.Option(
False,
Expand Down Expand Up @@ -653,22 +654,28 @@ def _run_command(self, cmd: Coroutine) -> None:
"""

async def _run():
if self.not_subtensor:
async with self.not_subtensor:
try:
if self.not_subtensor:
async with self.not_subtensor:
await cmd
else:
await cmd
else:
await cmd
except ConnectionRefusedError:
err_console.print(f"Unable to connect to chain: {self.not_subtensor}")
asyncio.create_task(cmd).cancel()
raise typer.Exit()
except ConnectionClosed:
raise typer.Exit()
except SubstrateRequestException as e:
err_console.print(str(e))
raise typer.Exit()

try:
if sys.version_info < (3, 10):
# For Python 3.9 or lower
return asyncio.get_event_loop().run_until_complete(_run())
else:
# For Python 3.10 or higher
return asyncio.run(_run())
except ConnectionRefusedError:
err_console.print(
f"Connection refused when connecting to chain: {self.not_subtensor}"
)
except ConnectionClosed:
pass
except SubstrateRequestException as e:
err_console.print(str(e))

def main_callback(
self,
Expand Down
Loading

0 comments on commit ccfb3a5

Please sign in to comment.