Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prompt option to all commands which use Confirm prompts #227

Merged
merged 2 commits into from
Nov 6, 2024
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
15 changes: 14 additions & 1 deletion bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,7 @@ def wallet_faucet(
"--max-successes",
help="Set the maximum number of times to successfully run the faucet for this command.",
),
prompt: bool = Options.prompt,
):
"""
Obtain test TAO tokens by performing Proof of Work (PoW).
Expand Down Expand Up @@ -1706,6 +1707,7 @@ def wallet_faucet(
output_in_place,
verbose,
max_successes,
prompt,
)
)

Expand Down Expand Up @@ -2420,7 +2422,8 @@ def wallet_sign(
if use_hotkey is None:
use_hotkey = Confirm.ask(
"Would you like to sign the transaction using your [red]hotkey[/red]?"
"\n[Type [red]y[/red] for [red]hotkey[/red] and [blue]n[/blue] for [blue]coldkey[/blue]] (default is [blue]coldkey[/blue])",
"\n[Type [red]y[/red] for [red]hotkey[/red] and [blue]n[/blue] for [blue]coldkey[/blue]] "
"(default is [blue]coldkey[/blue])",
default=False,
)

Expand Down Expand Up @@ -3653,6 +3656,7 @@ def stake_set_children(
wait_for_finalization: bool = Options.wait_for_finalization,
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
):
"""
Set child hotkeys on specified subnets.
Expand Down Expand Up @@ -3711,6 +3715,7 @@ def stake_set_children(
proportions=proportions,
wait_for_finalization=wait_for_finalization,
wait_for_inclusion=wait_for_inclusion,
prompt=prompt,
)
)

Expand All @@ -3736,6 +3741,7 @@ def stake_revoke_children(
wait_for_finalization: bool = Options.wait_for_finalization,
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
):
"""
Remove all children hotkeys on a specified subnet.
Expand Down Expand Up @@ -3770,6 +3776,7 @@ def stake_revoke_children(
netuid,
wait_for_inclusion,
wait_for_finalization,
prompt=prompt,
)
)

Expand Down Expand Up @@ -4075,6 +4082,7 @@ def subnets_pow_register(
"-tbp",
help="Set the number of threads per block for CUDA.",
),
prompt: bool = Options.prompt,
):
"""
Register a neuron (a subnet validator or a subnet miner) using Proof of Work (POW).
Expand Down Expand Up @@ -4112,6 +4120,7 @@ def subnets_pow_register(
use_cuda,
dev_id,
threads_per_block,
prompt=prompt,
)
)

Expand Down Expand Up @@ -4271,6 +4280,7 @@ def weights_reveal(
),
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
):
"""
Reveal weights for a specific subnet.
Expand Down Expand Up @@ -4342,6 +4352,7 @@ def weights_reveal(
weights,
salt,
__version_as_int__,
prompt=prompt,
)
)

Expand All @@ -4367,6 +4378,7 @@ def weights_commit(
),
quiet: bool = Options.quiet,
verbose: bool = Options.verbose,
prompt: bool = Options.prompt,
):
"""

Expand Down Expand Up @@ -4437,6 +4449,7 @@ def weights_commit(
weights,
salt,
__version_as_int__,
prompt=prompt,
)
)

Expand Down
12 changes: 7 additions & 5 deletions bittensor_cli/src/commands/stake/children_hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ async def set_children(
netuid: Optional[int] = None,
wait_for_inclusion: bool = True,
wait_for_finalization: bool = True,
prompt: bool = True,
):
"""Set children hotkeys."""
# Validate children SS58 addresses
Expand All @@ -520,7 +521,7 @@ async def set_children(
netuid=netuid,
hotkey=wallet.hotkey.ss58_address,
children_with_proportions=children_with_proportions,
prompt=True,
prompt=prompt,
wait_for_inclusion=wait_for_inclusion,
wait_for_finalization=wait_for_finalization,
)
Expand Down Expand Up @@ -549,7 +550,7 @@ async def set_children(
netuid=netuid,
hotkey=wallet.hotkey.ss58_address,
children_with_proportions=children_with_proportions,
prompt=False,
prompt=prompt,
wait_for_inclusion=True,
wait_for_finalization=False,
)
Expand All @@ -564,6 +565,7 @@ async def revoke_children(
netuid: Optional[int] = None,
wait_for_inclusion: bool = True,
wait_for_finalization: bool = True,
prompt: bool = True,
):
"""
Revokes the children hotkeys associated with a given network identifier (netuid).
Expand All @@ -575,7 +577,7 @@ async def revoke_children(
netuid=netuid,
hotkey=wallet.hotkey.ss58_address,
children_with_proportions=[],
prompt=True,
prompt=prompt,
wait_for_inclusion=wait_for_inclusion,
wait_for_finalization=wait_for_finalization,
)
Expand Down Expand Up @@ -604,7 +606,7 @@ async def revoke_children(
netuid=netuid,
hotkey=wallet.hotkey.ss58_address,
children_with_proportions=[],
prompt=False,
prompt=prompt,
wait_for_inclusion=True,
wait_for_finalization=False,
)
Expand Down Expand Up @@ -764,7 +766,7 @@ async def set_chk_take_subnet(subnet, chk_take):
netuid=netuid,
hotkey=wallet.hotkey.ss58_address,
take=take,
prompt=False,
prompt=prompt,
wait_for_inclusion=True,
wait_for_finalization=False,
)
Expand Down
3 changes: 2 additions & 1 deletion bittensor_cli/src/commands/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,15 @@ async def pow_register(
use_cuda,
dev_id,
threads_per_block,
prompt: bool,
):
"""Register neuron."""

await register_extrinsic(
subtensor,
wallet=wallet,
netuid=netuid,
prompt=True,
prompt=prompt,
tpb=threads_per_block,
update_interval=update_interval,
num_processes=processors,
Expand Down
3 changes: 2 additions & 1 deletion bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,13 +1413,14 @@ async def faucet(
output_in_place: bool,
log_verbose: bool,
max_successes: int = 3,
prompt: bool = True,
):
# TODO: - work out prompts to be passed through the cli
success = await run_faucet_extrinsic(
subtensor,
wallet,
tpb=threads_per_block,
prompt=False,
prompt=prompt,
update_interval=update_interval,
num_processes=processes,
cuda=use_cuda,
Expand Down
6 changes: 4 additions & 2 deletions bittensor_cli/src/commands/weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ async def reveal_weights(
weights: list[float],
salt: list[int],
version: int,
prompt: bool = True,
) -> None:
"""Reveal weights for a specific subnet."""
uids_ = np.array(
Expand All @@ -397,7 +398,7 @@ async def reveal_weights(
)
# Call the reveal function in the module set_weights from extrinsics package
extrinsic = SetWeightsExtrinsic(
subtensor, wallet, netuid, uids_, weights_, list(salt_), version
subtensor, wallet, netuid, uids_, weights_, list(salt_), version, prompt=prompt
)
success, message = await extrinsic.reveal(weight_uids, weight_vals)

Expand All @@ -415,6 +416,7 @@ async def commit_weights(
weights: list[float],
salt: list[int],
version: int,
prompt: bool = True,
):
"""Commits weights and then reveals them for a specific subnet"""
uids_ = np.array(
Expand All @@ -430,7 +432,7 @@ async def commit_weights(
dtype=np.int64,
)
extrinsic = SetWeightsExtrinsic(
subtensor, wallet, netuid, uids_, weights_, list(salt_), version
subtensor, wallet, netuid, uids_, weights_, list(salt_), version, prompt=prompt
)
success, message = await extrinsic.set_weights_extrinsic()
if success:
Expand Down
Loading