Skip to content

Commit

Permalink
Fix hyperparams setting. (#252)
Browse files Browse the repository at this point in the history
* Fix hyperparams setting.

* Updates check for registration_allowed

---------

Co-authored-by: ibraheem-opentensor <ibraheem@opentensor.dev>
  • Loading branch information
thewhaleking and ibraheem-opentensor authored Nov 26, 2024
1 parent 233fd05 commit 31adc4c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
10 changes: 10 additions & 0 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3904,6 +3904,16 @@ def sudo_set(
)
param_name = hyperparam_list[choice - 1]

if param_name in ["alpha_high", "alpha_low"]:
param_name = "alpha_values"
low_val = FloatPrompt.ask(
"Enter the new value for [dark_orange]alpha_low[/dark_orange]"
)
high_val = FloatPrompt.ask(
"Enter the new value for [dark_orange]alpha_high[/dark_orange]"
)
param_value = f"{low_val},{high_val}"

if not param_value:
param_value = Prompt.ask(
f"Enter the new value for [dark_orange]{param_name}[/dark_orange] in the VALUE column format"
Expand Down
22 changes: 13 additions & 9 deletions bittensor_cli/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,28 +318,32 @@ class WalletValidationTypes(Enum):


HYPERPARAMS = {
"serving_rate_limit": "sudo_set_serving_rate_limit",
"rho": "sudo_set_rho",
"kappa": "sudo_set_kappa",
"immunity_period": "sudo_set_immunity_period",
"min_allowed_weights": "sudo_set_min_allowed_weights",
"max_weights_limit": "sudo_set_max_weight_limit",
"tempo": "sudo_set_tempo",
"min_difficulty": "sudo_set_min_difficulty",
"max_difficulty": "sudo_set_max_difficulty",
"weights_version": "sudo_set_weights_version_key",
"weights_rate_limit": "sudo_set_weights_set_rate_limit",
"max_weight_limit": "sudo_set_max_weight_limit",
"immunity_period": "sudo_set_immunity_period",
"min_allowed_weights": "sudo_set_min_allowed_weights",
"adjustment_interval": "sudo_set_adjustment_interval",
"activity_cutoff": "sudo_set_activity_cutoff",
"network_registration_allowed": "sudo_set_network_registration_allowed",
"network_pow_registration_allowed": "sudo_set_network_pow_registration_allowed",
"target_regs_per_interval": "sudo_set_target_registrations_per_interval",
"min_burn": "sudo_set_min_burn",
"max_burn": "sudo_set_max_burn",
"bonds_moving_avg": "sudo_set_bonds_moving_average",
"max_regs_per_block": "sudo_set_max_registrations_per_block",
"serving_rate_limit": "sudo_set_serving_rate_limit",
"max_validators": "sudo_set_max_allowed_validators",
"adjustment_alpha": "sudo_set_adjustment_alpha",
"rho": "sudo_set_rho",
"kappa": "sudo_set_kappa",
"difficulty": "sudo_set_difficulty",
"bonds_moving_avg": "sudo_set_bonds_moving_average",
"commit_reveal_weights_interval": "sudo_set_commit_reveal_weights_interval",
"commit_reveal_weights_enabled": "sudo_set_commit_reveal_weights_enabled",
"alpha_values": "sudo_set_alpha_values",
"liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled",
"registration_allowed": "sudo_set_network_registration_allowed",
}

# Help Panels for cli help
Expand Down
7 changes: 4 additions & 3 deletions bittensor_cli/src/commands/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,20 @@ async def sudo_set_hyperparameter(

normalized_value: Union[str, bool]
if param_name in [
"network_registration_allowed",
"registration_allowed",
"network_pow_registration_allowed",
"commit_reveal_weights_enabled",
"liquid_alpha_enabled",
]:
normalized_value = param_value.lower() in ["true", "1"]
normalized_value = param_value.lower() in ["true", "True", "1"]
else:
normalized_value = param_value

is_allowed_value, value = allowed_value(param_name, normalized_value)
if not is_allowed_value:
err_console.print(
f"Hyperparameter {param_name} value is not within bounds. Value is {normalized_value} but must be {value}"
f"Hyperparameter [dark_orange]{param_name}[/dark_orange] value is not within bounds. "
f"Value is {normalized_value} but must be {value}"
)
return

Expand Down

0 comments on commit 31adc4c

Please sign in to comment.