diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e8a844132..21e90b2a96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index a3fcc7121b..21c8c7b46b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0 +7.1.1 diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 546d6d31f2..20693f11be 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -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 = ( diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index f20eac67a6..5c60d8c2c7 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -382,8 +382,13 @@ 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 + cli.config.value = ( + True + if (cli.config.value.lower() == "true" or cli.config.value == "1") + else False + ) subtensor.set_hyperparameter( wallet, diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index d2bc78f3aa..975de7dc9b 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -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, 1, 0]: + 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, 1, 0]: + 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, 1, 0]: + 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()