From c4b94c2b903ea2360a206dd93dccd139517ad4a6 Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 12 Jun 2024 07:34:14 -0400 Subject: [PATCH 01/17] feat: Implement Liquid Alpha Paramters --- bittensor/chain_data.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bittensor/chain_data.py b/bittensor/chain_data.py index 4a9f98244c..6734a18bd1 100644 --- a/bittensor/chain_data.py +++ b/bittensor/chain_data.py @@ -186,6 +186,8 @@ ["difficulty", "Compact"], ["commit_reveal_weights_interval", "Compact"], ["commit_reveal_weights_enabled", "bool"], + ["alpha_high", "Compact"], + ["alpha_low", "Compact"], ], }, } @@ -981,6 +983,8 @@ class SubnetHyperparameters: difficulty: int commit_reveal_weights_interval: int commit_reveal_weights_enabled: bool + alpha_high: int + alpha_low: int @classmethod def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]: @@ -1033,6 +1037,8 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters": difficulty=decoded["difficulty"], commit_reveal_weights_interval=decoded["commit_reveal_weights_interval"], commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"], + alpha_high=decoded["alpha_high"], + alpha_low=decoded["alpha_low"], ) def to_parameter_dict( From 3e5701a0c3511a3db28423ec67393772e9099a3e Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Mon, 17 Jun 2024 08:21:00 -0700 Subject: [PATCH 02/17] Added alpha hyperparams normalization --- bittensor/commands/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bittensor/commands/utils.py b/bittensor/commands/utils.py index 1694d3bc5e..8817b3baed 100644 --- a/bittensor/commands/utils.py +++ b/bittensor/commands/utils.py @@ -186,10 +186,10 @@ def filter_netuids_by_registered_hotkeys( ) netuids_with_registered_hotkeys.extend(netuids_list) - if cli.config.netuids == None or cli.config.netuids == []: + if cli.config.netuids is None: netuids = netuids_with_registered_hotkeys - elif cli.config.netuids != []: + else: netuids = [netuid for netuid in netuids if netuid in cli.config.netuids] netuids.extend(netuids_with_registered_hotkeys) @@ -216,6 +216,8 @@ def normalize_hyperparameters( "bonds_moving_avg": U64_NORMALIZED_FLOAT, "max_weight_limit": U16_NORMALIZED_FLOAT, "kappa": U16_NORMALIZED_FLOAT, + "alpha_high": U16_NORMALIZED_FLOAT, + "alpha_low": U16_NORMALIZED_FLOAT, "min_burn": Balance.from_rao, "max_burn": Balance.from_rao, } From 7ea74fc3884d3ef4ce2de8b95576cbc64d31074c Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Mon, 17 Jun 2024 10:31:20 -0700 Subject: [PATCH 03/17] Fixed if statement: filter_netuids_by_registered_hotkeys --- bittensor/commands/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/commands/utils.py b/bittensor/commands/utils.py index 8817b3baed..661cd818cc 100644 --- a/bittensor/commands/utils.py +++ b/bittensor/commands/utils.py @@ -186,7 +186,7 @@ def filter_netuids_by_registered_hotkeys( ) netuids_with_registered_hotkeys.extend(netuids_list) - if cli.config.netuids is None: + if not cli.config.netuids: netuids = netuids_with_registered_hotkeys else: From 669bb2fc3a7bcd25cf2b7ee7f145e83e9a47a1cd Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:19:51 -0700 Subject: [PATCH 04/17] add hyperparam liquid_alpha_enabled --- bittensor/chain_data.py | 3 +++ bittensor/commands/network.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/bittensor/chain_data.py b/bittensor/chain_data.py index 6734a18bd1..f655b8cc8f 100644 --- a/bittensor/chain_data.py +++ b/bittensor/chain_data.py @@ -188,6 +188,7 @@ ["commit_reveal_weights_enabled", "bool"], ["alpha_high", "Compact"], ["alpha_low", "Compact"], + ["liquid_alpha_enabled", "bool"], ], }, } @@ -985,6 +986,7 @@ class SubnetHyperparameters: commit_reveal_weights_enabled: bool alpha_high: int alpha_low: int + liquid_alpha_enabled: bool @classmethod def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]: @@ -1039,6 +1041,7 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters": commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"], alpha_high=decoded["alpha_high"], alpha_low=decoded["alpha_low"], + liquid_alpha_enabled=decoded["liquid_alpha_enabled"] ) def to_parameter_dict( diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 0843b71c70..24ad07592e 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -330,6 +330,9 @@ def add_args(parser: argparse.ArgumentParser): "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_high": "sudo_set_alpha_high", + "alpha_low": "sudo_set_alpha_low", + "liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled", } @@ -388,6 +391,7 @@ def _run( cli.config.param == "network_registration_allowed" or cli.config.param == "network_pow_registration_allowed" or cli.config.param == "commit_reveal_weights_enabled" + or cli.config.param == "liquid_alpha_enabled" ): cli.config.value = ( True From a2f7126a1317b51ab176b2bd42ab0f87cbb05ade Mon Sep 17 00:00:00 2001 From: opendansor Date: Tue, 18 Jun 2024 18:18:08 -0700 Subject: [PATCH 05/17] Add liquid alpha test --- .../subcommands/hyperparams/__init__.py | 0 .../hyperparams/test_liquid_alpha.py | 165 ++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 tests/e2e_tests/subcommands/hyperparams/__init__.py create mode 100644 tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py diff --git a/tests/e2e_tests/subcommands/hyperparams/__init__.py b/tests/e2e_tests/subcommands/hyperparams/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py new file mode 100644 index 0000000000..fc8a98e19f --- /dev/null +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -0,0 +1,165 @@ +import bittensor +from bittensor.commands import ( + RegisterCommand, + StakeCommand, + RegisterSubnetworkCommand, + SubnetSudoCommand, +) +from tests.e2e_tests.utils import setup_wallet, wait_epoch + +""" +Test the liquid alpha weights mechanism. + +Verify that: +* it can get enabled +* liquid alpha values cannot be set before the feature flag is set +* after feature flag, you can set alpha_high +* after feature flag, you can set alpha_low +* TODO: verify low cannot be greater than high +""" + + +def test_liquid_alpha_enabled(local_chain, capsys): + # Register root as Alice + keypair, exec_command, wallet = setup_wallet("//Alice") + exec_command(RegisterSubnetworkCommand, ["s", "create"]) + + # Verify subnet 1 created successfully + assert local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() + + # Register a neuron to the subnet + exec_command( + RegisterCommand, + [ + "s", + "register", + "--netuid", + "1", + ], + ) + + # Stake to become to top neuron after the first epoch + exec_command( + StakeCommand, + [ + "stake", + "add", + "--amount", + "100000", + ], + ) + + # Assert liquid alpha disabled + subtensor = bittensor.subtensor(network="ws://localhost:9945") + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).liquid_alpha_enabled is False + ), "Liquid alpha is enabled by default" + + # Attempt to set alpha high/low while disabled (should fail) + capsys.readouterr() + subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_high", + value=0.3, + wait_for_inclusion=True, + wait_for_finalization=True, + ) + output = capsys.readouterr() + assert ( + output.out + == "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: \n`Attempting to set alpha high/low while disabled`\n" + ) + + # Enable Liquid Alpha + exec_command( + SubnetSudoCommand, + [ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--wallet.name", + wallet.name, + "--param", + "liquid_alpha_enabled", + "--value", + "True", + "--wait_for_inclusion", + "True", + "--wait_for_finalization", + "True", + ], + ) + + subtensor = bittensor.subtensor(network="ws://localhost:9945") + assert subtensor.get_subnet_hyperparameters( + netuid=1 + ).liquid_alpha_enabled, "Failed to enable liquid alpha" + + output = capsys.readouterr().out + assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output + + # wait epoch after enabling liquid alpha (is this needed? Test without this) + wait_epoch(360, subtensor) + + # set high value + exec_command( + SubnetSudoCommand, + [ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--wallet.name", + wallet.name, + "--param", + "alpha_high", + "--value", + "0.3", + "--wait_for_inclusion", + "True", + "--wait_for_finalization", + "True", + ], + ) + + subtensor = bittensor.subtensor(network="ws://localhost:9945") + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 0.3 + ), "Failed to set alpha high" + + output = capsys.readouterr().out + assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output + + # Set low value + exec_command( + SubnetSudoCommand, + [ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--wallet.name", + wallet.name, + "--param", + "alpha_low", + "--value", + "0.1", + "--wait_for_inclusion", + "True", + "--wait_for_finalization", + "True", + ], + ) + + subtensor = bittensor.subtensor(network="ws://localhost:9945") + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 0.1 + ), "Failed to set alpha low" + + output = capsys.readouterr().out + assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output From bf2f1c53aeb763f2a36966272c4a16b45538e9e2 Mon Sep 17 00:00:00 2001 From: opendansor Date: Thu, 20 Jun 2024 12:14:09 -0700 Subject: [PATCH 06/17] Add test to cli parameters to be within bounds. --- bittensor/commands/network.py | 28 +++++++- .../integration_tests/test_cli_no_network.py | 65 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 24ad07592e..9899cede77 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -17,7 +17,7 @@ import argparse import bittensor -from . import defaults +from . import defaults # type: ignore from rich.prompt import Prompt from rich.table import Table from typing import List, Optional, Dict @@ -399,6 +399,10 @@ def _run( else False ) + is_allowed_value, error_message = allowed_value(cli.config.param, cli.config.value) + if not is_allowed_value: + raise ValueError(f"Hyperparameter {cli.config.param} value is not within bounds. Value is {cli.config.value} but must be {error_message}") + subtensor.set_hyperparameter( wallet, netuid=cli.config.netuid, @@ -642,3 +646,25 @@ def add_args(parser: argparse.ArgumentParser): default=False, ) bittensor.subtensor.add_args(parser) + + +def allowed_value(param, value): + """ + Check the allowed values on hyperparameters. Return False if value is out of bounds. + """ + # Reminder error message ends like: Value is {value} but must be {error_message}. (the second part of return statement) + # Check if value is a boolean, only allow boolean and floats + if not isinstance(value, bool): + try: + value = float(value) + except ValueError: + return False, "a number or a boolean" + if param == "alpha_high": + if value <= 0.8 or value >= 1 or not isinstance(value, float): + return False, "between 0.8 and 1" + if param == "alpha_low": + if value < 0 or value > 0.8 or not isinstance(value, float): + return False, "between 0 and 0.8" + + return True, "" + diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index cd9f89ee6a..f90badfda8 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1371,6 +1371,71 @@ 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_hyperparameter_allowed_values(self, mock_sub, __): + params = ["alpha_high", "alpha_low"] + + def _test_value_parsing(param: str, value: str): + cli = bittensor.cli( + args=[ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--param", + param, + "--value", + value, + "--wallet.name", + "mock", + ] + ) + should_raise_error = False + error_message = "" + + try: + float_value = float(value) + if param == "alpha_high" and (float_value <= 0.8 or float_value >= 1): + should_raise_error = True + error_message = "between 0.8 and 1" + elif param == "alpha_low" and (float_value < 0 or float_value > 0.8): + should_raise_error = True + error_message = "between 0 and 0.8" + except ValueError: + should_raise_error = True + error_message = "a number or a boolean" + except TypeError: + should_raise_error = True + error_message = "a number or a boolean" + + if isinstance(value, bool): + should_raise_error = True + error_message = "a number or a boolean" + + if should_raise_error: + with pytest.raises(ValueError) as exc_info: + cli.run() + assert ( + f"Hyperparameter {param} value is not within bounds. Value is {value} but must be {error_message}" + in str(exc_info.value) + ) + else: + 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, + value, + msg=f"Value argument not set correctly for {param}", + ) + + for param in params: + for value in [0.8, 11, 0.7, 0.9, 1, 0, True, "Some string"]: + as_str = str(value) + _test_value_parsing(param, as_str) + @patch("bittensor.wallet", new_callable=return_mock_wallet_factory) def test_network_registration_allowed_parse_boolean_argument(self, mock_sub, __): param = "network_registration_allowed" From e7ed3e240c39784714fbf679edee23f1dc2dc7f7 Mon Sep 17 00:00:00 2001 From: opendansor Date: Thu, 20 Jun 2024 15:56:04 -0700 Subject: [PATCH 07/17] Reset values for u16, u64. --- bittensor/commands/network.py | 8 +++---- .../hyperparams/test_liquid_alpha.py | 17 ++++++-------- .../integration_tests/test_cli_no_network.py | 23 +++++++++++++++---- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 9899cede77..a3b78984e7 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -660,11 +660,11 @@ def allowed_value(param, value): except ValueError: return False, "a number or a boolean" if param == "alpha_high": - if value <= 0.8 or value >= 1 or not isinstance(value, float): - return False, "between 0.8 and 1" + if value <= 52428 or value >= 65535 or not isinstance(value, float): + return False, "between 52428 and 65535" if param == "alpha_low": - if value < 0 or value > 0.8 or not isinstance(value, float): - return False, "between 0 and 0.8" + if value < 0 or value > 52428 or not isinstance(value, float): + return False, "between 0 and 52428" return True, "" diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index fc8a98e19f..cc7c6e5ee2 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -5,7 +5,7 @@ RegisterSubnetworkCommand, SubnetSudoCommand, ) -from tests.e2e_tests.utils import setup_wallet, wait_epoch +from tests.e2e_tests.utils import setup_wallet """ Test the liquid alpha weights mechanism. @@ -101,9 +101,6 @@ def test_liquid_alpha_enabled(local_chain, capsys): output = capsys.readouterr().out assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output - # wait epoch after enabling liquid alpha (is this needed? Test without this) - wait_epoch(360, subtensor) - # set high value exec_command( SubnetSudoCommand, @@ -118,7 +115,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): "--param", "alpha_high", "--value", - "0.3", + "53083", "--wait_for_inclusion", "True", "--wait_for_finalization", @@ -128,11 +125,11 @@ def test_liquid_alpha_enabled(local_chain, capsys): subtensor = bittensor.subtensor(network="ws://localhost:9945") assert ( - subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 0.3 + subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 53083 ), "Failed to set alpha high" output = capsys.readouterr().out - assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output + assert "✅ Hyper parameter alpha_high changed to 53083" in output # Set low value exec_command( @@ -148,7 +145,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): "--param", "alpha_low", "--value", - "0.1", + "6553", "--wait_for_inclusion", "True", "--wait_for_finalization", @@ -158,8 +155,8 @@ def test_liquid_alpha_enabled(local_chain, capsys): subtensor = bittensor.subtensor(network="ws://localhost:9945") assert ( - subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 0.1 + subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 6553 ), "Failed to set alpha low" output = capsys.readouterr().out - assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output + assert "✅ Hyper parameter alpha_low changed to 6553" in output diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index f90badfda8..1656908440 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1396,12 +1396,14 @@ def _test_value_parsing(param: str, value: str): try: float_value = float(value) - if param == "alpha_high" and (float_value <= 0.8 or float_value >= 1): + if param == "alpha_high" and ( + float_value <= 52428 or float_value >= 65535 + ): should_raise_error = True - error_message = "between 0.8 and 1" - elif param == "alpha_low" and (float_value < 0 or float_value > 0.8): + error_message = "between 52428 and 65535" + elif param == "alpha_low" and (float_value < 0 or float_value > 52428): should_raise_error = True - error_message = "between 0 and 0.8" + error_message = "between 0 and 52428" except ValueError: should_raise_error = True error_message = "a number or a boolean" @@ -1432,7 +1434,18 @@ def _test_value_parsing(param: str, value: str): ) for param in params: - for value in [0.8, 11, 0.7, 0.9, 1, 0, True, "Some string"]: + for value in [ + 0.8, + 11, + 52429, + 52428, + 52427, + -123, + 1, + 0, + True, + "Some string", + ]: as_str = str(value) _test_value_parsing(param, as_str) From 0e52d5247aea7ebedc5d5f0416a9096eb380df9d Mon Sep 17 00:00:00 2001 From: opendansor Date: Thu, 20 Jun 2024 16:49:03 -0700 Subject: [PATCH 08/17] Update test comment. --- tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index cc7c6e5ee2..daee46f13c 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -15,7 +15,6 @@ * liquid alpha values cannot be set before the feature flag is set * after feature flag, you can set alpha_high * after feature flag, you can set alpha_low -* TODO: verify low cannot be greater than high """ From ae459884c992e51576d2af7091a6e70f865c9a3d Mon Sep 17 00:00:00 2001 From: opendansor Date: Mon, 24 Jun 2024 12:01:01 -0700 Subject: [PATCH 09/17] modify network.py to allow passing multiple values to subtensor/substrate. filter values passed as a list in network.py modify data input/hyperparameters in chain_data.py complete e2e testing in test_liquid_alpha.py modify integration test in test_cli_no_network.py --- bittensor/chain_data.py | 10 ++--- bittensor/commands/network.py | 43 +++++++++++-------- bittensor/extrinsics/network.py | 30 +++++++++++-- .../hyperparams/test_liquid_alpha.py | 40 ++++------------- .../integration_tests/test_cli_no_network.py | 37 ++++++++-------- 5 files changed, 83 insertions(+), 77 deletions(-) diff --git a/bittensor/chain_data.py b/bittensor/chain_data.py index f655b8cc8f..1d424674f3 100644 --- a/bittensor/chain_data.py +++ b/bittensor/chain_data.py @@ -836,10 +836,10 @@ def list_of_tuple_from_vec_u8( cls, vec_u8: List[int] ) -> Dict[str, List["StakeInfo"]]: """Returns a list of StakeInfo objects from a ``vec_u8``.""" - decoded: Optional[list[tuple[str, list[object]]]] = ( - from_scale_encoding_using_type_string( - input_=vec_u8, type_string="Vec<(AccountId, Vec)>" - ) + decoded: Optional[ + list[tuple[str, list[object]]] + ] = from_scale_encoding_using_type_string( + input_=vec_u8, type_string="Vec<(AccountId, Vec)>" ) if decoded is None: @@ -1041,7 +1041,7 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters": commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"], alpha_high=decoded["alpha_high"], alpha_low=decoded["alpha_low"], - liquid_alpha_enabled=decoded["liquid_alpha_enabled"] + liquid_alpha_enabled=decoded["liquid_alpha_enabled"], ) def to_parameter_dict( diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index a3b78984e7..ad468f7b80 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -330,8 +330,7 @@ def add_args(parser: argparse.ArgumentParser): "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_high": "sudo_set_alpha_high", - "alpha_low": "sudo_set_alpha_low", + "alpha_values": "sudo_set_alpha_values", "liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled", } @@ -399,15 +398,15 @@ def _run( else False ) - is_allowed_value, error_message = allowed_value(cli.config.param, cli.config.value) + is_allowed_value, value = allowed_value(cli.config.param, cli.config.value) if not is_allowed_value: - raise ValueError(f"Hyperparameter {cli.config.param} value is not within bounds. Value is {cli.config.value} but must be {error_message}") + raise ValueError(f"Hyperparameter {cli.config.param} value is not within bounds. Value is {cli.config.value} but must be {value}") subtensor.set_hyperparameter( wallet, netuid=cli.config.netuid, parameter=cli.config.param, - value=cli.config.value, + value=value, prompt=not cli.config.no_prompt, ) @@ -654,17 +653,25 @@ def allowed_value(param, value): """ # Reminder error message ends like: Value is {value} but must be {error_message}. (the second part of return statement) # Check if value is a boolean, only allow boolean and floats - if not isinstance(value, bool): - try: - value = float(value) - except ValueError: - return False, "a number or a boolean" - if param == "alpha_high": - if value <= 52428 or value >= 65535 or not isinstance(value, float): - return False, "between 52428 and 65535" - if param == "alpha_low": - if value < 0 or value > 52428 or not isinstance(value, float): - return False, "between 0 and 52428" - - return True, "" + try: + if not isinstance(value, bool): + if param == "alpha_values": + # Split the string into individual values + alpha_low_str, alpha_high_str = value.split(",") + alpha_high = float(alpha_high_str) + alpha_low = float(alpha_low_str) + + # Check alpha_high value + if alpha_high <= 52428 or alpha_high >= 65535: + return False, f"between 52428 and 65535 for alpha_high (but is {alpha_high})" + + # Check alpha_low value + if alpha_low < 0 or alpha_low > 52428: + return False, f"between 0 and 52428 for alpha_low (but is {alpha_low})" + + return True, [alpha_low, alpha_high] + except ValueError: + return False, "a number or a boolean" + + return True, value diff --git a/bittensor/extrinsics/network.py b/bittensor/extrinsics/network.py index c03e5cf77b..16cbc0ed26 100644 --- a/bittensor/extrinsics/network.py +++ b/bittensor/extrinsics/network.py @@ -183,16 +183,38 @@ def set_hyperparameter_extrinsic( extrinsic_params = substrate.get_metadata_call_function( "AdminUtils", extrinsic ) - value_argument = extrinsic_params["fields"][ - len(extrinsic_params["fields"]) - 1 - ] + call_params = {"netuid": netuid} + + # if input value is a list, iterate through the list and assign values + if isinstance(value, list): + # Create an iterator for the list of values + value_iterator = iter(value) + # Iterate over all value arguments and add them to the call_params dictionary + for value_argument in extrinsic_params["fields"]: + if "netuid" not in str(value_argument["name"]): + # Assign the next value from the iterator + try: + call_params[str(value_argument["name"])] = next( + value_iterator + ) + except StopIteration: + raise ValueError( + "Not enough values provided in the list for all parameters" + ) + + else: + value_argument = extrinsic_params["fields"][ + len(extrinsic_params["fields"]) - 1 + ] + call_params[str(value_argument["name"])] = value # create extrinsic call call = substrate.compose_call( call_module="AdminUtils", call_function=extrinsic, - call_params={"netuid": netuid, str(value_argument["name"]): value}, + call_params=call_params, ) + extrinsic = substrate.create_signed_extrinsic( call=call, keypair=wallet.coldkey ) diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index daee46f13c..2e19754b20 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -23,6 +23,9 @@ def test_liquid_alpha_enabled(local_chain, capsys): keypair, exec_command, wallet = setup_wallet("//Alice") exec_command(RegisterSubnetworkCommand, ["s", "create"]) + # hyperparameter values + alpha_values = "6553, 53083" + # Verify subnet 1 created successfully assert local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() @@ -59,8 +62,8 @@ def test_liquid_alpha_enabled(local_chain, capsys): subtensor.set_hyperparameter( wallet=wallet, netuid=1, - parameter="alpha_high", - value=0.3, + parameter="alpha_values", + value=list(map(int, alpha_values.split(","))), wait_for_inclusion=True, wait_for_finalization=True, ) @@ -112,9 +115,9 @@ def test_liquid_alpha_enabled(local_chain, capsys): "--wallet.name", wallet.name, "--param", - "alpha_high", + "alpha_values", "--value", - "53083", + alpha_values, "--wait_for_inclusion", "True", "--wait_for_finalization", @@ -126,36 +129,9 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert ( subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 53083 ), "Failed to set alpha high" - - output = capsys.readouterr().out - assert "✅ Hyper parameter alpha_high changed to 53083" in output - - # Set low value - exec_command( - SubnetSudoCommand, - [ - "sudo", - "set", - "hyperparameters", - "--netuid", - "1", - "--wallet.name", - wallet.name, - "--param", - "alpha_low", - "--value", - "6553", - "--wait_for_inclusion", - "True", - "--wait_for_finalization", - "True", - ], - ) - - subtensor = bittensor.subtensor(network="ws://localhost:9945") assert ( subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 6553 ), "Failed to set alpha low" output = capsys.readouterr().out - assert "✅ Hyper parameter alpha_low changed to 6553" in output + assert "✅ Hyper parameter alpha_values changed to [6553.0, 53083.0]" in output diff --git a/tests/integration_tests/test_cli_no_network.py b/tests/integration_tests/test_cli_no_network.py index 1656908440..e3a3d6a49c 100644 --- a/tests/integration_tests/test_cli_no_network.py +++ b/tests/integration_tests/test_cli_no_network.py @@ -1372,8 +1372,12 @@ 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_hyperparameter_allowed_values(self, mock_sub, __): - params = ["alpha_high", "alpha_low"] + def test_hyperparameter_allowed_values( + self, + mock_sub, + __, + ): + params = ["alpha_values"] def _test_value_parsing(param: str, value: str): cli = bittensor.cli( @@ -1395,13 +1399,13 @@ def _test_value_parsing(param: str, value: str): error_message = "" try: - float_value = float(value) - if param == "alpha_high" and ( - float_value <= 52428 or float_value >= 65535 - ): + alpha_low_str, alpha_high_str = value.strip("[]").split(",") + alpha_high = float(alpha_high_str) + alpha_low = float(alpha_low_str) + if alpha_high <= 52428 or alpha_high >= 65535: should_raise_error = True error_message = "between 52428 and 65535" - elif param == "alpha_low" and (float_value < 0 or float_value > 52428): + elif alpha_low < 0 or alpha_low > 52428: should_raise_error = True error_message = "between 0 and 52428" except ValueError: @@ -1435,18 +1439,15 @@ def _test_value_parsing(param: str, value: str): for param in params: for value in [ - 0.8, - 11, - 52429, - 52428, - 52427, - -123, - 1, - 0, - True, - "Some string", + [0.8, 11], + [52429, 52428], + [52427, 53083], + [6553, 53083], + [-123, None], + [1, 0], + [True, "Some string"], ]: - as_str = str(value) + as_str = str(value).strip("[]") _test_value_parsing(param, as_str) @patch("bittensor.wallet", new_callable=return_mock_wallet_factory) From 24284d02e514a1aaa23e63de29773261575f7a61 Mon Sep 17 00:00:00 2001 From: opendansor Date: Mon, 24 Jun 2024 12:15:38 -0700 Subject: [PATCH 10/17] Update bittensor/commands/network.py Co-authored-by: gus-opentensor <158077861+gus-opentensor@users.noreply.github.com> --- bittensor/commands/network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index ad468f7b80..5e91e5e892 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -647,7 +647,7 @@ def add_args(parser: argparse.ArgumentParser): bittensor.subtensor.add_args(parser) -def allowed_value(param, value): +def allowed_value(param: str, value: Union[str, bool, float]) -> Tuple[bool, Union[str, list[float], float]]: """ Check the allowed values on hyperparameters. Return False if value is out of bounds. """ From 26d35f54272cb1c9b1e815e9425c3a86d3b75a1d Mon Sep 17 00:00:00 2001 From: opendansor Date: Mon, 24 Jun 2024 12:17:24 -0700 Subject: [PATCH 11/17] Import types --- bittensor/commands/network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 5e91e5e892..17468f7f2b 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -20,7 +20,7 @@ from . import defaults # type: ignore from rich.prompt import Prompt from rich.table import Table -from typing import List, Optional, Dict +from typing import List, Optional, Dict, Union, Tuple from .utils import ( get_delegates_details, DelegatesDetails, From 7302956017664ec0cd7ed828ed503333ffabdf4c Mon Sep 17 00:00:00 2001 From: opendansor Date: Mon, 24 Jun 2024 12:26:56 -0700 Subject: [PATCH 12/17] Ruff formatting --- bittensor/chain_data.py | 8 ++++---- bittensor/commands/network.py | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bittensor/chain_data.py b/bittensor/chain_data.py index 1d424674f3..e62ad19621 100644 --- a/bittensor/chain_data.py +++ b/bittensor/chain_data.py @@ -836,10 +836,10 @@ def list_of_tuple_from_vec_u8( cls, vec_u8: List[int] ) -> Dict[str, List["StakeInfo"]]: """Returns a list of StakeInfo objects from a ``vec_u8``.""" - decoded: Optional[ - list[tuple[str, list[object]]] - ] = from_scale_encoding_using_type_string( - input_=vec_u8, type_string="Vec<(AccountId, Vec)>" + decoded: Optional[list[tuple[str, list[object]]]] = ( + from_scale_encoding_using_type_string( + input_=vec_u8, type_string="Vec<(AccountId, Vec)>" + ) ) if decoded is None: diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 17468f7f2b..b5fada55a9 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -400,7 +400,9 @@ def _run( is_allowed_value, value = allowed_value(cli.config.param, cli.config.value) if not is_allowed_value: - raise ValueError(f"Hyperparameter {cli.config.param} value is not within bounds. Value is {cli.config.value} but must be {value}") + raise ValueError( + f"Hyperparameter {cli.config.param} value is not within bounds. Value is {cli.config.value} but must be {value}" + ) subtensor.set_hyperparameter( wallet, @@ -647,7 +649,9 @@ def add_args(parser: argparse.ArgumentParser): bittensor.subtensor.add_args(parser) -def allowed_value(param: str, value: Union[str, bool, float]) -> Tuple[bool, Union[str, list[float], float]]: +def allowed_value( + param: str, value: Union[str, bool, float] +) -> Tuple[bool, Union[str, list[float], float]]: """ Check the allowed values on hyperparameters. Return False if value is out of bounds. """ @@ -663,15 +667,20 @@ def allowed_value(param: str, value: Union[str, bool, float]) -> Tuple[bool, Uni # Check alpha_high value if alpha_high <= 52428 or alpha_high >= 65535: - return False, f"between 52428 and 65535 for alpha_high (but is {alpha_high})" + return ( + False, + f"between 52428 and 65535 for alpha_high (but is {alpha_high})", + ) # Check alpha_low value if alpha_low < 0 or alpha_low > 52428: - return False, f"between 0 and 52428 for alpha_low (but is {alpha_low})" + return ( + False, + f"between 0 and 52428 for alpha_low (but is {alpha_low})", + ) return True, [alpha_low, alpha_high] except ValueError: return False, "a number or a boolean" return True, value - From 8fb6e635f0f8f9a3f6698747314dff7d503129fd Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:27:46 -0700 Subject: [PATCH 13/17] expand test_liquid_alpha cases --- .../hyperparams/test_liquid_alpha.py | 146 +++++++++++++++++- 1 file changed, 138 insertions(+), 8 deletions(-) diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index 2e19754b20..5eeca9f179 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -58,8 +58,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): ), "Liquid alpha is enabled by default" # Attempt to set alpha high/low while disabled (should fail) - capsys.readouterr() - subtensor.set_hyperparameter( + result = subtensor.set_hyperparameter( wallet=wallet, netuid=1, parameter="alpha_values", @@ -67,10 +66,10 @@ def test_liquid_alpha_enabled(local_chain, capsys): wait_for_inclusion=True, wait_for_finalization=True, ) - output = capsys.readouterr() + assert result is None + output = capsys.readouterr().out assert ( - output.out - == "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: \n`Attempting to set alpha high/low while disabled`\n" + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" in output ) # Enable Liquid Alpha @@ -95,7 +94,6 @@ def test_liquid_alpha_enabled(local_chain, capsys): ], ) - subtensor = bittensor.subtensor(network="ws://localhost:9945") assert subtensor.get_subnet_hyperparameters( netuid=1 ).liquid_alpha_enabled, "Failed to enable liquid alpha" @@ -103,7 +101,96 @@ def test_liquid_alpha_enabled(local_chain, capsys): output = capsys.readouterr().out assert "✅ Hyper parameter liquid_alpha_enabled changed to True" in output - # set high value + exec_command( + SubnetSudoCommand, + [ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--wallet.name", + wallet.name, + "--param", + "alpha_values", + "--value", + "87, 54099", + "--wait_for_inclusion", + "True", + "--wait_for_finalization", + "True", + ], + ) + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 54099 + ), "Failed to set alpha high" + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 87 + ), "Failed to set alpha low" + + u16_max = 65535 + # Set alpha high too low + alpha_high_too_low = (u16_max * 4 // 5) - 1 # One less than the minimum acceptable value + result = subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_values", + value=[6553, alpha_high_too_low], + wait_for_inclusion=True, + wait_for_finalization=True, + ) + assert result is None + output = capsys.readouterr().out + assert ( + "❌ Failed: Subtensor returned `AlphaHighTooLow (Module)` error. This means: `Alpha high is too low: alpha_high > 0.8`" in output + ) + + alpha_high_too_high = u16_max + 1 # One more than the max acceptable value + try: + result = subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_values", + value=[6553, alpha_high_too_high], + wait_for_inclusion=True, + wait_for_finalization=True, + ) + assert result is None, "Expected not to be able to set alpha value above u16" + except Exception as e: + assert str(e) == "65536 out of range for u16", f"Unexpected error: {e}" + + # Set alpha low too low + alpha_low_too_low = 0 + result = subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_values", + value=[alpha_low_too_low, 53083], + wait_for_inclusion=True, + wait_for_finalization=True, + ) + assert result is None + output = capsys.readouterr().out + assert ( + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output + ) + + # Set alpha low too high + alpha_low_too_high = (u16_max * 4 // 5) + 1 # One more than the maximum acceptable value + result = subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_values", + value=[alpha_low_too_high, 53083], + wait_for_inclusion=True, + wait_for_finalization=True, + ) + assert result is None + output = capsys.readouterr().out + assert ( + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output + ) + exec_command( SubnetSudoCommand, [ @@ -125,7 +212,6 @@ def test_liquid_alpha_enabled(local_chain, capsys): ], ) - subtensor = bittensor.subtensor(network="ws://localhost:9945") assert ( subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 53083 ), "Failed to set alpha high" @@ -135,3 +221,47 @@ def test_liquid_alpha_enabled(local_chain, capsys): output = capsys.readouterr().out assert "✅ Hyper parameter alpha_values changed to [6553.0, 53083.0]" in output + + # Disable Liquid Alpha + exec_command( + SubnetSudoCommand, + [ + "sudo", + "set", + "hyperparameters", + "--netuid", + "1", + "--wallet.name", + wallet.name, + "--param", + "liquid_alpha_enabled", + "--value", + "False", + "--wait_for_inclusion", + "True", + "--wait_for_finalization", + "True", + ], + ) + + assert subtensor.get_subnet_hyperparameters( + netuid=1 + ).liquid_alpha_enabled is False, "Failed to disable liquid alpha" + + output = capsys.readouterr().out + assert "✅ Hyper parameter liquid_alpha_enabled changed to False" in output + + result = subtensor.set_hyperparameter( + wallet=wallet, + netuid=1, + parameter="alpha_values", + value=list(map(int, alpha_values.split(","))), + wait_for_inclusion=True, + wait_for_finalization=True, + ) + assert result is None + output = capsys.readouterr().out + assert ( + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" in output + ) + From 79873660d6be2a98abde2f45f8a85abccc146732 Mon Sep 17 00:00:00 2001 From: Gus Date: Wed, 26 Jun 2024 12:23:36 -0400 Subject: [PATCH 14/17] chore:lint --- .../hyperparams/test_liquid_alpha.py | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index 5eeca9f179..4d647feebc 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -69,7 +69,8 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" in output + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" + in output ) # Enable Liquid Alpha @@ -130,7 +131,9 @@ def test_liquid_alpha_enabled(local_chain, capsys): u16_max = 65535 # Set alpha high too low - alpha_high_too_low = (u16_max * 4 // 5) - 1 # One less than the minimum acceptable value + alpha_high_too_low = ( + u16_max * 4 // 5 + ) - 1 # One less than the minimum acceptable value result = subtensor.set_hyperparameter( wallet=wallet, netuid=1, @@ -142,7 +145,8 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaHighTooLow (Module)` error. This means: `Alpha high is too low: alpha_high > 0.8`" in output + "❌ Failed: Subtensor returned `AlphaHighTooLow (Module)` error. This means: `Alpha high is too low: alpha_high > 0.8`" + in output ) alpha_high_too_high = u16_max + 1 # One more than the max acceptable value @@ -172,11 +176,14 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" + in output ) # Set alpha low too high - alpha_low_too_high = (u16_max * 4 // 5) + 1 # One more than the maximum acceptable value + alpha_low_too_high = ( + u16_max * 4 // 5 + ) + 1 # One more than the maximum acceptable value result = subtensor.set_hyperparameter( wallet=wallet, netuid=1, @@ -188,7 +195,8 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" + in output ) exec_command( @@ -244,9 +252,9 @@ def test_liquid_alpha_enabled(local_chain, capsys): ], ) - assert subtensor.get_subnet_hyperparameters( - netuid=1 - ).liquid_alpha_enabled is False, "Failed to disable liquid alpha" + assert ( + subtensor.get_subnet_hyperparameters(netuid=1).liquid_alpha_enabled is False + ), "Failed to disable liquid alpha" output = capsys.readouterr().out assert "✅ Hyper parameter liquid_alpha_enabled changed to False" in output @@ -262,6 +270,6 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" in output + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" + in output ) - From 0b02f4af4490ddc3a4e33e747309c5afb271ae5a Mon Sep 17 00:00:00 2001 From: opendansor Date: Wed, 26 Jun 2024 10:22:08 -0700 Subject: [PATCH 15/17] Fix LA test --- .../subcommands/hyperparams/test_liquid_alpha.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py index 4d647feebc..cf2522b788 100644 --- a/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py +++ b/tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py @@ -69,7 +69,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: \n`Attempting to set alpha high/low while disabled`" in output ) @@ -145,7 +145,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaHighTooLow (Module)` error. This means: `Alpha high is too low: alpha_high > 0.8`" + "❌ Failed: Subtensor returned `AlphaHighTooLow (Module)` error. This means: \n`Alpha high is too low: alpha_high > 0.8`" in output ) @@ -176,7 +176,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: \n`Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output ) @@ -195,7 +195,7 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: `Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" + "❌ Failed: Subtensor returned `AlphaLowOutOfRange (Module)` error. This means: \n`Alpha low is out of range: alpha_low > 0 && alpha_low < 0.8`" in output ) @@ -270,6 +270,6 @@ def test_liquid_alpha_enabled(local_chain, capsys): assert result is None output = capsys.readouterr().out assert ( - "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: `Attempting to set alpha high/low while disabled`" + "❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: \n`Attempting to set alpha high/low while disabled`" in output ) From 383f695a692b715b09a8ab59ee61d78ac3e78464 Mon Sep 17 00:00:00 2001 From: opendansor Date: Wed, 26 Jun 2024 11:19:11 -0700 Subject: [PATCH 16/17] Skip faucet test --- tests/e2e_tests/subcommands/wallet/test_faucet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_tests/subcommands/wallet/test_faucet.py b/tests/e2e_tests/subcommands/wallet/test_faucet.py index a6a729d3f5..ce9983f03b 100644 --- a/tests/e2e_tests/subcommands/wallet/test_faucet.py +++ b/tests/e2e_tests/subcommands/wallet/test_faucet.py @@ -11,7 +11,7 @@ setup_wallet, ) - +@pytest.mark.skip @pytest.mark.parametrize("local_chain", [False], indirect=True) def test_faucet(local_chain): # Register root as Alice From 8554c104a909fa2ba44c992d4ea1681166c11479 Mon Sep 17 00:00:00 2001 From: opendansor Date: Wed, 26 Jun 2024 11:19:11 -0700 Subject: [PATCH 17/17] Skip faucet test --- tests/e2e_tests/subcommands/wallet/test_faucet.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e_tests/subcommands/wallet/test_faucet.py b/tests/e2e_tests/subcommands/wallet/test_faucet.py index a6a729d3f5..a79cce47cc 100644 --- a/tests/e2e_tests/subcommands/wallet/test_faucet.py +++ b/tests/e2e_tests/subcommands/wallet/test_faucet.py @@ -12,6 +12,7 @@ ) +@pytest.mark.skip @pytest.mark.parametrize("local_chain", [False], indirect=True) def test_faucet(local_chain): # Register root as Alice