Skip to content

Commit 1a3a944

Browse files
authored
Rename not_subtensor to subtensor (#157)
1 parent d2c1968 commit 1a3a944

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

bittensor_cli/cli.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,10 @@ class CLIManager:
383383
:var stake_app: the Typer app as it relates to stake commands
384384
:var sudo_app: the Typer app as it relates to sudo commands
385385
:var subnets_app: the Typer app as it relates to subnets commands
386-
:var not_subtensor: the `SubtensorInterface` object passed to the various commands that require it
386+
:var subtensor: the `SubtensorInterface` object passed to the various commands that require it
387387
"""
388388

389-
not_subtensor: Optional[SubtensorInterface]
389+
subtensor: Optional[SubtensorInterface]
390390
app: typer.Typer
391391
config_app: typer.Typer
392392
wallet_app: typer.Typer
@@ -419,7 +419,7 @@ def __init__(self):
419419
"COLDKEY": True,
420420
},
421421
}
422-
self.not_subtensor = None
422+
self.subtensor = None
423423
self.config_base_path = os.path.expanduser(defaults.config.base_path)
424424
self.config_path = os.path.expanduser(defaults.config.path)
425425

@@ -743,22 +743,22 @@ def initialize_chain(
743743
) -> SubtensorInterface:
744744
"""
745745
Intelligently initializes a connection to the chain, depending on the supplied (or in config) values. Sets the
746-
`self.not_subtensor` object to this created connection.
746+
`self.subtensor` object to this created connection.
747747
748748
:param network: Network name (e.g. finney, test, etc.) or
749749
chain endpoint (e.g. ws://127.0.0.1:9945, wss://entrypoint-finney.opentensor.ai:443)
750750
"""
751-
if not self.not_subtensor:
751+
if not self.subtensor:
752752
if network:
753-
self.not_subtensor = SubtensorInterface(network)
753+
self.subtensor = SubtensorInterface(network)
754754
elif self.config["network"]:
755-
self.not_subtensor = SubtensorInterface(self.config["network"])
755+
self.subtensor = SubtensorInterface(self.config["network"])
756756
console.print(
757757
f"Using the specified network [dark_orange]{self.config['network']}[/dark_orange] from config"
758758
)
759759
else:
760-
self.not_subtensor = SubtensorInterface(defaults.subtensor.network)
761-
return self.not_subtensor
760+
self.subtensor = SubtensorInterface(defaults.subtensor.network)
761+
return self.subtensor
762762

763763
def _run_command(self, cmd: Coroutine) -> None:
764764
"""
@@ -767,16 +767,14 @@ def _run_command(self, cmd: Coroutine) -> None:
767767

768768
async def _run():
769769
try:
770-
if self.not_subtensor:
771-
async with self.not_subtensor:
770+
if self.subtensor:
771+
async with self.subtensor:
772772
result = await cmd
773773
else:
774774
result = await cmd
775775
return result
776776
except (ConnectionRefusedError, ssl.SSLError):
777-
err_console.print(
778-
f"Unable to connect to the chain: {self.not_subtensor}"
779-
)
777+
err_console.print(f"Unable to connect to the chain: {self.subtensor}")
780778
asyncio.create_task(cmd).cancel()
781779
raise typer.Exit()
782780
except ConnectionClosed:
@@ -1431,7 +1429,7 @@ def wallet_swap_hotkey(
14311429
)
14321430
self.initialize_chain(network)
14331431
return self._run_command(
1434-
wallets.swap_hotkey(original_wallet, new_wallet, self.not_subtensor, prompt)
1432+
wallets.swap_hotkey(original_wallet, new_wallet, self.subtensor, prompt)
14351433
)
14361434

14371435
def wallet_inspect(
@@ -1501,7 +1499,7 @@ def wallet_inspect(
15011499
return self._run_command(
15021500
wallets.inspect(
15031501
wallet,
1504-
self.not_subtensor,
1502+
self.subtensor,
15051503
netuids_filter=netuids,
15061504
all_wallets=all_wallets,
15071505
)
@@ -1890,7 +1888,7 @@ def wallet_check_ck_swap(
18901888
self.verbosity_handler(quiet, verbose)
18911889
wallet = self.wallet_ask(wallet_name, wallet_path, wallet_hotkey)
18921890
self.initialize_chain(network)
1893-
return self._run_command(wallets.check_coldkey_swap(wallet, self.not_subtensor))
1891+
return self._run_command(wallets.check_coldkey_swap(wallet, self.subtensor))
18941892

18951893
def wallet_create_wallet(
18961894
self,

0 commit comments

Comments
 (0)