Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4597,7 +4597,9 @@ def sudo_set(
"Param name not supplied with `--no-prompt` flag. Cannot continue"
)
return False
hyperparam_list = [field.name for field in fields(SubnetHyperparameters)]
hyperparam_list = sorted(
[field.name for field in fields(SubnetHyperparameters)]
)
console.print("Available hyperparameters:\n")
for idx, param in enumerate(hyperparam_list, start=1):
console.print(f" {idx}. {param}")
Expand Down
3 changes: 2 additions & 1 deletion bittensor_cli/src/commands/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ async def get_hyperparameters(
dict_out = []

normalized_values = normalize_hyperparameters(subnet, json_output=json_output)
for param, value, norm_value in normalized_values:
sorted_values = sorted(normalized_values, key=lambda x: x[0])
for param, value, norm_value in sorted_values:
if not json_output:
table.add_row(" " + param, value, norm_value)
else:
Expand Down
21 changes: 11 additions & 10 deletions tests/e2e_tests/test_staking_sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,20 +396,17 @@ def test_staking(local_chain, wallet_setup):
hyperparams = exec_command_alice(
command="sudo",
sub_command="get",
extra_args=[
"--chain",
"ws://127.0.0.1:9945",
"--netuid",
netuid,
],
extra_args=["--chain", "ws://127.0.0.1:9945", "--netuid", netuid, "--json-out"],
)

# Parse all hyperparameters and single out max_burn in TAO
all_hyperparams = hyperparams.stdout.splitlines()
max_burn_tao = all_hyperparams[22].split()[2].strip("\u200e")
all_hyperparams = json.loads(hyperparams.stdout)
max_burn_tao = next(
filter(lambda x: x["hyperparameter"] == "max_burn", all_hyperparams)
)["value"]

# Assert max_burn is 100 TAO from default
assert Balance.from_tao(float(max_burn_tao)) == Balance.from_tao(100.0)
assert Balance.from_rao(int(max_burn_tao)) == Balance.from_tao(100.0)

hyperparams_json = exec_command_alice(
command="sudo",
Expand Down Expand Up @@ -468,7 +465,11 @@ def test_staking(local_chain, wallet_setup):

# Parse updated hyperparameters
all_updated_hyperparams = updated_hyperparams.stdout.splitlines()
updated_max_burn_tao = all_updated_hyperparams[22].split()[2].strip("\u200e")
updated_max_burn_tao = (
next(filter(lambda x: x[3:11] == "max_burn", all_updated_hyperparams))
.split()[2]
.strip("\u200e")
)

# Assert max_burn is now 10 TAO
assert Balance.from_tao(float(updated_max_burn_tao)) == Balance.from_tao(10)
Expand Down
Loading