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
27 changes: 20 additions & 7 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def __init__(self):
self.weights_app,
name="weights",
short_help="Weights commands, aliases: `wt`, `weight`",
hidden=True,
)
self.app.add_typer(self.weights_app, name="wt", hidden=True)
self.app.add_typer(self.weights_app, name="weight", hidden=True)
Expand Down Expand Up @@ -2174,7 +2175,7 @@ def root_set_weights(
distribution.
"""
self.verbosity_handler(quiet, verbose)
netuids = list_prompt(netuids, int, "Enter netuids")
netuids = list_prompt(netuids, int, "Enter netuids (e.g: 1, 4, 6)")
wallet = self.wallet_ask(
wallet_name,
wallet_path,
Expand All @@ -2183,7 +2184,7 @@ def root_set_weights(
validate=WV.WALLET_AND_HOTKEY,
)
if not weights:
weights = list_prompt([], float, "Weights: e.g. 0.02, 0.03, 0.01 ")
weights = list_prompt([], float, "Weights (e.g. 0.02, 0.03, 0.01)")
self._run_command(
root.set_weights(
wallet, self.initialize_chain(network, chain), netuids, weights, prompt
Expand Down Expand Up @@ -2264,7 +2265,7 @@ def root_boost(
"--amount",
"--increase",
"-a",
prompt=True,
prompt="Boost amount (added to existing weight)",
help="Amount (float) to boost, (e.g. 0.01)",
),
prompt: bool = Options.prompt,
Expand Down Expand Up @@ -2310,7 +2311,7 @@ def root_slash(
"--amount",
"--decrease",
"-a",
prompt=True,
prompt="Slash amount (subtracted from the existing weight)",
help="Amount (float) to boost, (e.g. 0.01)",
),
prompt: bool = Options.prompt,
Expand Down Expand Up @@ -2358,6 +2359,7 @@ def root_senate_vote(
None,
"--proposal",
"--proposal-hash",
prompt="Enter the proposal hash",
help="The hash of the proposal to vote on.",
),
prompt: bool = Options.prompt,
Expand Down Expand Up @@ -2863,13 +2865,24 @@ def root_list_delegates(
console application. It prints directly to the console and does not return any value.
"""
self.verbosity_handler(quiet, verbose)
network_to_use = network or self.config["network"]
if network_to_use not in ["local", "test"]:

if chain:
sub = self.initialize_chain(network, chain)

elif network == "finney":
sub = self.initialize_chain(
"archive", "wss://archive.chain.opentensor.ai:443"
)

elif self.config.get("chain"):
sub = self.initialize_chain(network, self.config.get("chain"))

elif self.config.get("network") == "finney":
sub = self.initialize_chain(
"archive", "wss://archive.chain.opentensor.ai:443"
)
else:
sub = self.initialize_chain(network_to_use, chain)
sub = self.initialize_chain(network, chain)

return self._run_command(root.list_delegates(sub))

Expand Down
10 changes: 7 additions & 3 deletions bittensor_cli/src/commands/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ async def _get_delegate_by_hotkey(ss58: str) -> Optional[DelegateInfo]:
return True
if current_take is None or current_take < take_u16:
console.print(
"Current take is either not set or is lower than the new one. Will use increase_take"
f"Current take is {float(delegate.take):.4f}. Increasing to {take:.4f}."
)
with console.status(
f":satellite: Sending decrease_take_extrinsic call on [white]{subtensor}[/white] ..."
Expand All @@ -463,7 +463,7 @@ async def _get_delegate_by_hotkey(ss58: str) -> Optional[DelegateInfo]:
success, err = await subtensor.sign_and_send_extrinsic(call, wallet)

else:
console.print("Current take is higher than the new one. Will use decrease_take")
console.print(f"Current take is {float(delegate.take):.4f}. Decreasing to {take:.4f}.")
with console.status(
f":satellite: Sending increase_take_extrinsic call on [white]{subtensor}[/white] ..."
):
Expand Down Expand Up @@ -935,9 +935,13 @@ async def get_weights(
no_wrap=True,
)

if not rows:
err_console.print("No weights exist on the root network.")
return

# Adding rows
for row in rows:
new_row = [row[0]] + row[_min_lim:_max_lim]
new_row = [row[0]] + row[_min_lim + 1:_max_lim + 1]
table.add_row(*new_row)

return console.print(table)
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e_tests/test_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_root_commands(local_chain, wallet_setup):

# Capture delegate information and assert correct values
# First row are labels, entries start from the second row
bob_delegate_info = check_delegates.stdout.splitlines()[4].split()
bob_delegate_info = check_delegates.stdout.splitlines()[6].split()

# INDEX: First uid is always 0
assert bob_delegate_info[0] == "0"
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_root_commands(local_chain, wallet_setup):
],
)
# Capture delegate information after setting take
bob_delegate_info = check_delegates.stdout.splitlines()[4].split()
bob_delegate_info = check_delegates.stdout.splitlines()[6].split()

# Take percentage: This should be 18% by default
take_percentage = float(bob_delegate_info[6].strip("%")) / 100
Expand Down