Skip to content

Commit 96448c3

Browse files
committed
Improvements to subnets, stake, sudo
1 parent c1195a6 commit 96448c3

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

bittensor_cli/src/commands/stake/stake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,8 +1786,8 @@ def table_substakes(hotkey_: str, substakes: list[StakeInfo]):
17861786
rows.append(
17871787
[
17881788
str(netuid), # Number
1789-
symbol, # Symbol
1790-
f"{substake_.stake.tao:,.4f} {symbol}", # Stake (a)
1789+
symbol if netuid != 0 else "\u03A4", # Symbol
1790+
f"{substake_.stake.tao:,.4f} {symbol}" if netuid != 0 else f"{symbol} {substake_.stake.tao:,.4f}", # Stake (a)
17911791
f"{pool.price.tao:.4f} τ/{symbol}", # Rate (t/a)
17921792
f"{tao_ownership}", # TAO equiv
17931793
f"{tao_value}", # Exchange Value (α x τ/α)

bittensor_cli/src/commands/subnets.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ def create_table(subnets, global_weights, identities):
257257

258258
# Prepare cells
259259
netuid_cell = str(netuid)
260-
symbol_cell = f"{subnet.symbol}"
260+
symbol_cell = f"{subnet.symbol}" if netuid != 0 else "\u03A4"
261261
subnet_name_cell = SUBNETS.get(netuid, "~")
262-
emission_cell = f"{emission_tao:,.4f}"
262+
emission_cell = f"τ {emission_tao:,.4f}"
263263
price_cell = f"{subnet.price.tao:.4f} τ/{symbol}"
264-
tao_in_cell = f"{subnet.tao_in.tao:,.4f} τ"
265-
alpha_in_cell = f"{subnet.alpha_in.tao:,.4f} {symbol}"
266-
alpha_out_cell = f"{subnet.alpha_out.tao:,.5f} {symbol}"
264+
tao_in_cell = f"τ {subnet.tao_in.tao:,.4f}"
265+
alpha_in_cell = f"{subnet.alpha_in.tao:,.4f} {symbol}" if netuid != 0 else f"{symbol} {subnet.alpha_in.tao:,.4f}"
266+
alpha_out_cell = f"{subnet.alpha_out.tao:,.5f} {symbol}" if netuid != 0 else f"{symbol} {subnet.alpha_out.tao:,.5f}"
267267
tempo_cell = f"{subnet.blocks_since_last_step}/{subnet.tempo}"
268268
global_weight_cell = (
269269
f"{global_weight:.4f}" if global_weight is not None else "N/A"
@@ -304,22 +304,22 @@ def create_table(subnets, global_weights, identities):
304304

305305
# Live mode
306306
def create_table_live(subnets, global_weights, identities, previous_data):
307-
def format_cell(value, previous_value, unit="", precision=4):
307+
def format_cell(value, previous_value, unit="", unit_first=False, precision=4):
308308
if previous_value is not None:
309309
change = value - previous_value
310-
if change > 0:
310+
if change > 0.01:
311311
change_text = (
312-
f" [pale_green3](+{change:.{precision}f}{unit})[/pale_green3]"
312+
f" [pale_green3](+{change:.2f})[/pale_green3]"
313313
)
314-
elif change < 0:
314+
elif change < -0.01:
315315
change_text = (
316-
f" [hot_pink3]({change:.{precision}f}{unit})[/hot_pink3]"
316+
f" [hot_pink3]({change:.2f})[/hot_pink3]"
317317
)
318318
else:
319319
change_text = ""
320320
else:
321321
change_text = ""
322-
return f"{value:,.{precision}f}{unit}{change_text}"
322+
return f"{value:,.{precision}f} {unit}{change_text}" if not unit_first else f"{unit} {value:,.{precision}f}{change_text}"
323323

324324
rows = []
325325
current_data = {} # To store current values for comparison in the next update
@@ -350,27 +350,33 @@ def format_cell(value, previous_value, unit="", precision=4):
350350

351351
# Prepare cells
352352
netuid_cell = str(netuid)
353-
symbol_cell = f"{subnet.symbol}"
353+
symbol_cell = f"{subnet.symbol}" if netuid != 0 else "\u03A4"
354354
subnet_name_cell = SUBNETS.get(netuid, "~")
355+
if netuid is 0:
356+
unit_first = True
357+
else:
358+
unit_first = False
355359
emission_cell = format_cell(
356-
emission_tao, prev.get("emission_tao"), unit="", precision=4
360+
emission_tao, prev.get("emission_tao"), unit="τ", unit_first=True, precision=4
357361
)
358362
price_cell = format_cell(
359-
subnet.price.tao, prev.get("price"), unit=f" τ/{symbol}", precision=4
363+
subnet.price.tao, prev.get("price"), unit=f"τ/{symbol}", precision=4
360364
)
361365
tao_in_cell = format_cell(
362-
subnet.tao_in.tao, prev.get("tao_in"), unit=" τ", precision=4
366+
subnet.tao_in.tao, prev.get("tao_in"), unit="τ", unit_first=True, precision=4
363367
)
364368
alpha_in_cell = format_cell(
365369
subnet.alpha_in.tao,
366370
prev.get("alpha_in"),
367-
unit=f" {symbol}",
371+
unit=f"{symbol}",
372+
unit_first=unit_first,
368373
precision=4,
369374
)
370375
alpha_out_cell = format_cell(
371376
subnet.alpha_out.tao,
372377
prev.get("alpha_out"),
373-
unit=f" {symbol}",
378+
unit=f"{symbol}",
379+
unit_first=unit_first,
374380
precision=5,
375381
)
376382

@@ -688,10 +694,10 @@ async def show_root():
688694
console.print(
689695
f"[{COLOR_PALETTE['GENERAL']['SUBHEADING']}]Root Network (Subnet 0)[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]"
690696
f"\n Rate: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{root_info.price.tao:.4f} τ/{root_info.symbol}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
691-
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]0 τ[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
692-
f"\n TAO Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{root_info.tao_in.tao:,.4f} τ[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
693-
f"\n Alpha Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{root_info.alpha_in.tao:,.4f} {root_info.symbol}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
694-
f"\n Stake: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{root_info.alpha_out.tao:,.5f} {root_info.symbol}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
697+
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{root_info.symbol} 0[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
698+
f"\n TAO Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{root_info.symbol} {root_info.tao_in.tao:,.4f}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
699+
f"\n Alpha Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{root_info.symbol}{root_info.alpha_in.tao:,.4f}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
700+
f"\n Stake: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{root_info.symbol} {root_info.alpha_out.tao:,.5f}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
695701
f"\n Tempo: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{root_info.blocks_since_last_step}/{root_info.tempo}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
696702
)
697703
console.print(
@@ -885,8 +891,8 @@ async def show_subnet(netuid_: int):
885891
f"[{COLOR_PALETTE['GENERAL']['SUBHEADING']}]Subnet {netuid_}{subnet_name_display}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]"
886892
f"\n Owner: [{COLOR_PALETTE['GENERAL']['COLDKEY']}]{subnet_info.owner}{' (' + owner_identity + ')' if owner_identity else ''}[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]"
887893
f"\n Rate: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{subnet_info.price.tao:.4f} τ/{subnet_info.symbol}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
888-
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]{subnet_info.emission.tao:,.4f} τ[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
889-
f"\n TAO Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{subnet_info.tao_in.tao:,.4f} τ[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
894+
f"\n Emission: [{COLOR_PALETTE['GENERAL']['HOTKEY']}]τ {subnet_info.emission.tao:,.4f}[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
895+
f"\n TAO Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]τ {subnet_info.tao_in.tao:,.4f}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
890896
f"\n Alpha Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{subnet_info.alpha_in.tao:,.4f} {subnet_info.symbol}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
891897
f"\n Stake: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{subnet_info.alpha_out.tao:,.5f} {subnet_info.symbol}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
892898
f"\n Tempo: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{subnet_info.blocks_since_last_step}/{subnet_info.tempo}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"

bittensor_cli/src/commands/sudo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from rich.prompt import Confirm
99
from scalecodec import GenericCall
1010

11-
from bittensor_cli.src import HYPERPARAMS, DelegatesDetails, COLOR_PALETTE
11+
from bittensor_cli.src import HYPERPARAMS, DelegatesDetails, COLOR_PALETTE, SUBNETS
1212
from bittensor_cli.src.bittensor.chain_data import decode_account_id
1313
from bittensor_cli.src.bittensor.utils import (
1414
console,
@@ -500,8 +500,10 @@ async def get_hyperparameters(subtensor: "SubtensorInterface", netuid: int):
500500
Column("[white]VALUE", style=COLOR_PALETTE['SUDO']['VALUE']),
501501
Column("[white]NORMALIZED", style=COLOR_PALETTE['SUDO']['NORMALIZED']),
502502
title=f"[{COLOR_PALETTE['GENERAL']['HEADER']}]\nSubnet Hyperparameters\n NETUID: "
503-
f"[{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{netuid}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]"
504-
f" - Network: [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{subtensor.network}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]\n",
503+
f"[{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{netuid}"
504+
f"{f' ({SUBNETS.get(netuid)})' if SUBNETS.get(netuid) else ''}"
505+
f"[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]"
506+
f" - Network: [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{subtensor.network}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]\n",
505507
show_footer=True,
506508
width=None,
507509
pad_edge=False,

0 commit comments

Comments
 (0)