Skip to content

Commit

Permalink
Fixes s show/ and delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheem-opentensor committed Jan 9, 2025
1 parent 2c978a8 commit 35ce549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 14 additions & 8 deletions bittensor_cli/src/commands/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,10 @@ async def show(
) -> Optional[str]:
async def show_root():
all_subnets = await subtensor.get_all_subnet_dynamic_info()
root_info = all_subnets[0]
root_info = next((s for s in all_subnets if s.netuid == 0), None)
if root_info is None:
print_error("The root subnet does not exist")
raise typer.Exit()

hex_bytes_result, identities, old_identities = await asyncio.gather(
subtensor.query_runtime_api(
Expand Down Expand Up @@ -1035,24 +1038,27 @@ async def show_subnet(netuid_: int):
subtensor.query_all_identities(),
subtensor.get_delegate_identities(),
)
subnet_info = _subnet_info[netuid_]
subnet_info = next((s for s in _subnet_info if s.netuid == netuid_), None)
if subnet_info is None:
print_error(f"Subnet {netuid_} does not exist")
raise typer.Exit()

if (bytes_result := hex_bytes_result) is None:
err_console.print(f"Subnet {netuid_} does not exist")
return
print_error(f"Subnet {netuid_} does not exist")
raise typer.Exit()

if bytes_result.startswith("0x"):
bytes_result = bytes.fromhex(bytes_result[2:])

subnet_state: "SubnetState" = SubnetState.from_vec_u8(bytes_result)
if subnet_info is None:
err_console.print(f"Subnet {netuid_} does not exist")
return
print_error(f"Subnet {netuid_} does not exist")
raise typer.Exit()
elif len(subnet_state.hotkeys) == 0:
err_console.print(
print_error(
f"Subnet {netuid_} is currently empty with 0 UIDs registered."
)
return
raise typer.Exit()

# Define table properties
table = Table(
Expand Down
6 changes: 5 additions & 1 deletion bittensor_cli/src/commands/sudo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
from typing import TYPE_CHECKING, Union, Optional

import typer
from bittensor_wallet import Wallet
from bittensor_wallet.errors import KeyFileError
from rich import box
Expand Down Expand Up @@ -495,7 +496,10 @@ async def get_hyperparameters(subtensor: "SubtensorInterface", netuid: int):
return False
subnet = await subtensor.get_subnet_hyperparameters(netuid)
_subnet_info = await subtensor.get_all_subnet_dynamic_info()
subnet_info = _subnet_info[netuid]
subnet_info = next((s for s in _subnet_info if s.netuid == netuid), None)
if subnet_info is None:
print_error(f"Subnet with netuid {netuid} does not exist.")
raise typer.Exit()

table = Table(
Column("[white]HYPERPARAMETER", style=COLOR_PALETTE['SUDO']['HYPERPARAMETER']),
Expand Down

0 comments on commit 35ce549

Please sign in to comment.