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

[hotfix] commit_reveal_weights_enabled argument parsing #2003

Merged
merged 11 commits into from
Jun 12, 2024
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 7.1.1 / 2024-06-11

## What's Changed
* commit_reveal_weights_enabled argument parsing hotfix by @camfairchild in https://github.com/opentensor/bittensor/pull/2003

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.1.0...v7.1.1

## 7.1.0 / 2024-06-05

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0
7.1.1
2 changes: 1 addition & 1 deletion bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
nest_asyncio.apply()

# Bittensor code and protocol version.
__version__ = "7.1.0"
__version__ = "7.1.1"

version_split = __version__.split(".")
__version_as_int__: int = (
Expand Down
1 change: 1 addition & 0 deletions bittensor/commands/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def _run(
if (
cli.config.param == "network_registration_allowed"
or cli.config.param == "network_pow_registration_allowed"
or cli.config.param == "commit_reveal_weights_enabled"
):
cli.config.value = True if cli.config.value.lower() == "true" else False

Expand Down
116 changes: 116 additions & 0 deletions tests/integration_tests/test_cli_no_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,122 @@ def test_vote_command_prompt_proposal_hash(self, _):
# NO prompt happened
mock_ask_prompt.assert_not_called()

@patch("bittensor.wallet", new_callable=return_mock_wallet_factory)
def test_commit_reveal_weights_enabled_parse_boolean_argument(self, mock_sub, __):
param = "commit_reveal_weights_enabled"

def _test_value_parsing(parsed_value: bool, modified: str):
cli = bittensor.cli(
args=[
"sudo",
"set",
"--netuid",
"1",
"--param",
param,
"--value",
modified,
"--wallet.name",
"mock",
]
)
cli.run()

_, kwargs = mock_sub.call_args
passed_config = kwargs["config"]
self.assertEqual(passed_config.param, param, msg="Incorrect param")
self.assertEqual(
passed_config.value,
parsed_value,
msg=f"Boolean argument not correctly for {modified}",
)

for boolean_value in [True, False]:
as_str = str(boolean_value)

_test_value_parsing(boolean_value, as_str)
_test_value_parsing(boolean_value, as_str.capitalize())
_test_value_parsing(boolean_value, as_str.upper())
_test_value_parsing(boolean_value, as_str.lower())

@patch("bittensor.wallet", new_callable=return_mock_wallet_factory)
def test_network_registration_allowed_parse_boolean_argument(self, mock_sub, __):
param = "network_registration_allowed"

def _test_value_parsing(parsed_value: bool, modified: str):
cli = bittensor.cli(
args=[
"sudo",
"set",
"--netuid",
"1",
"--param",
param,
"--value",
modified,
"--wallet.name",
"mock",
]
)
cli.run()

_, kwargs = mock_sub.call_args
passed_config = kwargs["config"]
self.assertEqual(passed_config.param, param, msg="Incorrect param")
self.assertEqual(
passed_config.value,
parsed_value,
msg=f"Boolean argument not correctly for {modified}",
)

for boolean_value in [True, False]:
as_str = str(boolean_value)

_test_value_parsing(boolean_value, as_str)
_test_value_parsing(boolean_value, as_str.capitalize())
_test_value_parsing(boolean_value, as_str.upper())
_test_value_parsing(boolean_value, as_str.lower())

@patch("bittensor.wallet", new_callable=return_mock_wallet_factory)
def test_network_pow_registration_allowed_parse_boolean_argument(
self, mock_sub, __
):
param = "network_pow_registration_allowed"

def _test_value_parsing(parsed_value: bool, modified: str):
cli = bittensor.cli(
args=[
"sudo",
"set",
"--netuid",
"1",
"--param",
param,
"--value",
modified,
"--wallet.name",
"mock",
]
)
cli.run()

_, kwargs = mock_sub.call_args
passed_config = kwargs["config"]
self.assertEqual(passed_config.param, param, msg="Incorrect param")
self.assertEqual(
passed_config.value,
parsed_value,
msg=f"Boolean argument not correctly for {modified}",
)

for boolean_value in [True, False]:
as_str = str(boolean_value)

_test_value_parsing(boolean_value, as_str)
_test_value_parsing(boolean_value, as_str.capitalize())
_test_value_parsing(boolean_value, as_str.upper())
_test_value_parsing(boolean_value, as_str.lower())


if __name__ == "__main__":
unittest.main()