Skip to content

Commit 3a710dc

Browse files
authored
Merge pull request #512 from opentensor/release/9.7.1
Release/9.7.1
2 parents ded01cf + 302bc8f commit 3a710dc

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 9.7.1/2025-06-26
4+
5+
## What's Changed
6+
* Convert hyperparams from strings by @thewhaleking in https://github.com/opentensor/btcli/pull/510
7+
* Ensure we parse strings for param names by @thewhaleking in https://github.com/opentensor/btcli/pull/511
8+
9+
**Full Changelog**: https://github.com/opentensor/btcli/compare/v9.7.0...v9.7.1
10+
311
## 9.7.0/2025-06-16
412

513
## What's Changed

bittensor_cli/src/bittensor/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ def u64_normalized_float(x: int) -> float:
122122
return float(x) / float(U64_MAX)
123123

124124

125+
def string_to_u64(value: str) -> int:
126+
"""Converts a string to u64"""
127+
return float_to_u64(float(value))
128+
129+
125130
def float_to_u64(value: float) -> int:
126131
"""Converts a float to a u64 int"""
127132
# Ensure the input is within the expected range
@@ -142,6 +147,11 @@ def u64_to_float(value: int) -> float:
142147
return min(value / u64_max, 1.0) # Ensure the result is never greater than 1.0
143148

144149

150+
def string_to_u16(value: str) -> int:
151+
"""Converts a string to a u16 int"""
152+
return float_to_u16(float(value))
153+
154+
145155
def float_to_u16(value: float) -> int:
146156
# Ensure the input is within the expected range
147157
if not (0 <= value <= 1):

bittensor_cli/src/commands/sudo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
normalize_hyperparameters,
1919
unlock_key,
2020
blocks_to_duration,
21-
float_to_u64,
22-
float_to_u16,
2321
json_console,
22+
string_to_u16,
23+
string_to_u64,
2424
)
2525

2626
if TYPE_CHECKING:
@@ -108,7 +108,7 @@ def type_converter_with_retry(type_, val, arg_name):
108108
except ValueError:
109109
return type_converter_with_retry(type_, None, arg_name)
110110

111-
arg_types = {"bool": string_to_bool, "u16": float_to_u16, "u64": float_to_u64}
111+
arg_types = {"bool": string_to_bool, "u16": string_to_u16, "u64": string_to_u64}
112112
arg_type_output = {"bool": "bool", "u16": "float", "u64": "float"}
113113

114114
call_crafter = {"netuid": netuid}
@@ -234,9 +234,9 @@ async def set_hyperparameter_extrinsic(
234234
if isinstance(value, list):
235235
# Ensure that there are enough values for all non-netuid parameters
236236
non_netuid_fields = [
237-
param["name"]
237+
pn_str
238238
for param in extrinsic_params["fields"]
239-
if "netuid" not in param["name"]
239+
if "netuid" not in (pn_str := str(param["name"]))
240240
]
241241

242242
if len(value) < len(non_netuid_fields):
@@ -246,7 +246,7 @@ async def set_hyperparameter_extrinsic(
246246
return False
247247

248248
call_params.update(
249-
{str(name): val for name, val in zip(non_netuid_fields, value)}
249+
{name: val for name, val in zip(non_netuid_fields, value)}
250250
)
251251

252252
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bittensor-cli"
7-
version = "9.7.0"
7+
version = "9.7.1"
88
description = "Bittensor CLI"
99
readme = "README.md"
1010
authors = [

tests/e2e_tests/test_staking_sudo.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,31 @@ def test_staking(local_chain, wallet_setup):
533533
assert yuma3_val["value"] is True
534534
assert yuma3_val["normalized_value"] is True
535535
print("✅ Passed staking and sudo commands")
536+
537+
change_arbitrary_hyperparam = exec_command_alice(
538+
command="sudo",
539+
sub_command="set",
540+
extra_args=[
541+
"--wallet-path",
542+
wallet_path_alice,
543+
"--wallet-name",
544+
wallet_alice.name,
545+
"--hotkey",
546+
wallet_alice.hotkey_str,
547+
"--chain",
548+
"ws://127.0.0.1:9945",
549+
"--netuid",
550+
netuid,
551+
"--param",
552+
"sudo_set_bonds_penalty", # arbitrary hyperparam
553+
"--value",
554+
"0", # int/float value
555+
"--no-prompt",
556+
"--json-output",
557+
],
558+
)
559+
change_arbitrary_hyperparam_json = json.loads(change_arbitrary_hyperparam.stdout)
560+
assert change_arbitrary_hyperparam_json["success"] is True, (
561+
change_arbitrary_hyperparam.stdout,
562+
change_arbitrary_hyperparam.stderr,
563+
)

0 commit comments

Comments
 (0)