From 8346c21af6d44b5bd7b8a1d2d2bf84d31a4982c9 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 17:26:18 -0400 Subject: [PATCH 01/10] fix commit_reveal_weights_enabled argument parsing --- bittensor/commands/network.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index f20eac67a6..8c738330d7 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -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 From 32f18721f4ae5259357c6aa2fef5f6f1459b76bb Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 17:27:04 -0400 Subject: [PATCH 02/10] bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a3fcc7121b..21c8c7b46b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0 +7.1.1 From d6b0550d1ce6dae151afc0582ddd272f0ca44d25 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 17:28:41 -0400 Subject: [PATCH 03/10] add changelog entry --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 066b9a926d8ccf004b53971ff4c251c180a3f802 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 17:31:04 -0400 Subject: [PATCH 04/10] bump version in-code also --- bittensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = ( From a8eca40050e38bcc98a9958dfb570ae35fdfca79 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 18:13:37 -0400 Subject: [PATCH 05/10] add test for hotfix bug --- .../integration_tests/test_cli_no_network.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index d2bc78f3aa..41037d1f09 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1333,6 +1333,37 @@ 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()) + + if __name__ == "__main__": unittest.main() From c3696aa1a8f8b86032232da2bfd9887bf3a5d6d2 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 18:15:00 -0400 Subject: [PATCH 06/10] add tests for other params --- .../integration_tests/test_cli_no_network.py | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index 41037d1f09..e30affb5f3 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1363,6 +1363,65 @@ def _test_value_parsing(parsed_value: bool, modified: str): _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__": From 0b475d534142bd463a3a9a9befec1792cd5683a5 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 11 Jun 2024 18:16:05 -0400 Subject: [PATCH 07/10] run black --- .../integration_tests/test_cli_no_network.py | 64 +++++++++++++------ 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index e30affb5f3..ebe2065b7e 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1342,10 +1342,14 @@ def _test_value_parsing(parsed_value: bool, modified: str): args=[ "sudo", "set", - "--netuid", "1", - "--param", param, - "--value", modified, - "--wallet.name", "mock", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", ] ) cli.run() @@ -1353,8 +1357,12 @@ def _test_value_parsing(parsed_value: bool, modified: str): _, 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}") - + 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) @@ -1372,10 +1380,14 @@ def _test_value_parsing(parsed_value: bool, modified: str): args=[ "sudo", "set", - "--netuid", "1", - "--param", param, - "--value", modified, - "--wallet.name", "mock", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", ] ) cli.run() @@ -1383,8 +1395,12 @@ def _test_value_parsing(parsed_value: bool, modified: str): _, 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}") - + 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) @@ -1394,7 +1410,9 @@ def _test_value_parsing(parsed_value: bool, modified: str): _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, __): + 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): @@ -1402,10 +1420,14 @@ def _test_value_parsing(parsed_value: bool, modified: str): args=[ "sudo", "set", - "--netuid", "1", - "--param", param, - "--value", modified, - "--wallet.name", "mock", + "--netuid", + "1", + "--param", + param, + "--value", + modified, + "--wallet.name", + "mock", ] ) cli.run() @@ -1413,8 +1435,12 @@ def _test_value_parsing(parsed_value: bool, modified: str): _, 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}") - + 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) From 0405867652daf5b7939a3e72ef825581d6deec7d Mon Sep 17 00:00:00 2001 From: opendansor Date: Tue, 11 Jun 2024 16:46:47 -0700 Subject: [PATCH 08/10] Add 1 and 0 as booleans. --- bittensor/commands/network.py | 2 +- tests/integration_tests/test_cli_no_network.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 8c738330d7..c434bfedb2 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -384,7 +384,7 @@ def _run( 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 ebe2065b7e..b41776a642 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1363,7 +1363,7 @@ def _test_value_parsing(parsed_value: bool, modified: str): msg=f"Boolean argument not correctly for {modified}", ) - for boolean_value in [True, False]: + for boolean_value in [True, False, 1, 0]: as_str = str(boolean_value) _test_value_parsing(boolean_value, as_str) From 7ee133bf64007627075fbf7ae0bf58624544381e Mon Sep 17 00:00:00 2001 From: opendansor Date: Tue, 11 Jun 2024 16:46:47 -0700 Subject: [PATCH 09/10] Add 1 and 0 as booleans. --- bittensor/commands/network.py | 2 +- tests/integration_tests/test_cli_no_network.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 8c738330d7..c434bfedb2 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -384,7 +384,7 @@ def _run( 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 ebe2065b7e..975de7dc9b 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1363,7 +1363,7 @@ def _test_value_parsing(parsed_value: bool, modified: str): msg=f"Boolean argument not correctly for {modified}", ) - for boolean_value in [True, False]: + for boolean_value in [True, False, 1, 0]: as_str = str(boolean_value) _test_value_parsing(boolean_value, as_str) @@ -1401,7 +1401,7 @@ def _test_value_parsing(parsed_value: bool, modified: str): msg=f"Boolean argument not correctly for {modified}", ) - for boolean_value in [True, False]: + for boolean_value in [True, False, 1, 0]: as_str = str(boolean_value) _test_value_parsing(boolean_value, as_str) @@ -1441,7 +1441,7 @@ def _test_value_parsing(parsed_value: bool, modified: str): msg=f"Boolean argument not correctly for {modified}", ) - for boolean_value in [True, False]: + for boolean_value in [True, False, 1, 0]: as_str = str(boolean_value) _test_value_parsing(boolean_value, as_str) From ed3c69cfc470ffdb3cfebcd5d6e0c81950059cf7 Mon Sep 17 00:00:00 2001 From: opendansor Date: Tue, 11 Jun 2024 16:59:15 -0700 Subject: [PATCH 10/10] black --- bittensor/commands/network.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index c434bfedb2..5c60d8c2c7 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -384,7 +384,11 @@ def _run( 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" or cli.config.value == "1") else False + cli.config.value = ( + True + if (cli.config.value.lower() == "true" or cli.config.value == "1") + else False + ) subtensor.set_hyperparameter( wallet,