From f04e2c339a531ec6592f3b8b235a23651e264d6b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 17 May 2024 13:27:59 -0700 Subject: [PATCH 1/4] Updated version to 6.12.1 --- VERSION | 2 +- bittensor/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index d4e6cb4293..ff61e18689 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.12.0 +6.12.1 diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 93d2aa4ca6..3f5c1d99ec 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -28,7 +28,7 @@ # Bittensor code and protocol version. -__version__ = "6.12.0" +__version__ = "6.12.1" version_split = __version__.split(".") __version_as_int__: int = ( From c3bbc92877d98d777a22c2db4731c7eebf46e98c Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 17 May 2024 13:28:52 -0700 Subject: [PATCH 2/4] Hotfix if the subnet UID is not in the Subnets. --- bittensor/utils/weight_utils.py | 15 ++++++---- tests/unit_tests/utils/test_utils.py | 32 +++++++++++++++++---- tests/unit_tests/utils/test_weight_utils.py | 32 +++++++++++++++++---- 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/bittensor/utils/weight_utils.py b/bittensor/utils/weight_utils.py index 0c5c944a0e..c9012452cc 100644 --- a/bittensor/utils/weight_utils.py +++ b/bittensor/utils/weight_utils.py @@ -1,4 +1,4 @@ -""" Conversion for weight between chain representation and torch tensor +""" Conversion for weight between chain representation and np.array """ # The MIT License (MIT) @@ -22,6 +22,8 @@ import bittensor from typing import Tuple, List +from bittensor.btlogging import logging + U32_MAX = 4294967295 U16_MAX = 65535 @@ -123,11 +125,14 @@ def convert_root_weight_uids_and_vals_to_tensor( for uid_j, wij in list(zip(uids, weights)): if uid_j in subnets: index_s = subnets.index(uid_j) + row_weights[index_s] = float( + wij + ) # assumes max-upscaled values (w_max = U16_MAX). else: - raise Exception("Incorrect Subnet {uid_j} in {subnets}") - row_weights[index_s] = float( - wij - ) # assumes max-upscaled values (w_max = U16_MAX). + logging.warning( + f"Incorrect Subnet uid {uid_j} in Subnets {subnets}. The subnet is unavailable at the moment." + ) + continue row_sum = row_weights.sum() if row_sum > 0: row_weights /= row_sum # normalize diff --git a/tests/unit_tests/utils/test_utils.py b/tests/unit_tests/utils/test_utils.py index 0875d921e0..42c08bd6a7 100644 --- a/tests/unit_tests/utils/test_utils.py +++ b/tests/unit_tests/utils/test_utils.py @@ -17,6 +17,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import logging import torch import bittensor.utils.weight_utils as weight_utils import pytest @@ -230,19 +231,38 @@ def test_convert_root_weight_uids_and_vals_to_tensor_edge_cases( @pytest.mark.parametrize( "test_id, n, uids, weights, subnets, exception", [ - ("error-1", 3, [1, 3], [100, 200], [1, 2], Exception), # uid not in subnets - ("error-2", 3, [1, 2, 3], [100, 200], [1], Exception), # More uids than subnets + # uid not in subnets + ( + "error-1", + 3, + [1, 3], + [100, 200], + [1, 2], + "The subnet is unavailable at the moment.", + ), + # More uids than subnets + ( + "error-2", + 3, + [1, 2, 3], + [100, 200], + [1], + "The subnet is unavailable at the moment.", + ), ], ) def test_convert_root_weight_uids_and_vals_to_tensor_error_cases( - test_id, n, uids, weights, subnets, exception + test_id, n, uids, weights, subnets, exception, caplog ): - # Act and Assert - with pytest.raises(exception): + with caplog.at_level(logging.WARNING): weight_utils.convert_root_weight_uids_and_vals_to_tensor( n, uids, weights, subnets ) - print(f"Failed {test_id}") + + assert any( + exception in record.message and record.levelname == "WARNING" + for record in caplog.records + ) @pytest.mark.parametrize( diff --git a/tests/unit_tests/utils/test_weight_utils.py b/tests/unit_tests/utils/test_weight_utils.py index 0875d921e0..42c08bd6a7 100644 --- a/tests/unit_tests/utils/test_weight_utils.py +++ b/tests/unit_tests/utils/test_weight_utils.py @@ -17,6 +17,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import logging import torch import bittensor.utils.weight_utils as weight_utils import pytest @@ -230,19 +231,38 @@ def test_convert_root_weight_uids_and_vals_to_tensor_edge_cases( @pytest.mark.parametrize( "test_id, n, uids, weights, subnets, exception", [ - ("error-1", 3, [1, 3], [100, 200], [1, 2], Exception), # uid not in subnets - ("error-2", 3, [1, 2, 3], [100, 200], [1], Exception), # More uids than subnets + # uid not in subnets + ( + "error-1", + 3, + [1, 3], + [100, 200], + [1, 2], + "The subnet is unavailable at the moment.", + ), + # More uids than subnets + ( + "error-2", + 3, + [1, 2, 3], + [100, 200], + [1], + "The subnet is unavailable at the moment.", + ), ], ) def test_convert_root_weight_uids_and_vals_to_tensor_error_cases( - test_id, n, uids, weights, subnets, exception + test_id, n, uids, weights, subnets, exception, caplog ): - # Act and Assert - with pytest.raises(exception): + with caplog.at_level(logging.WARNING): weight_utils.convert_root_weight_uids_and_vals_to_tensor( n, uids, weights, subnets ) - print(f"Failed {test_id}") + + assert any( + exception in record.message and record.levelname == "WARNING" + for record in caplog.records + ) @pytest.mark.parametrize( From fd2442db8bb8aad55ced2ac3b748b04ebdc73292 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Fri, 17 May 2024 14:53:42 -0700 Subject: [PATCH 3/4] Hotfix 6.12.1: Fixed typo --- bittensor/utils/weight_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/weight_utils.py b/bittensor/utils/weight_utils.py index c9012452cc..9190da4896 100644 --- a/bittensor/utils/weight_utils.py +++ b/bittensor/utils/weight_utils.py @@ -1,4 +1,4 @@ -""" Conversion for weight between chain representation and np.array +""" Conversion for weight between chain representation and torch tensor """ # The MIT License (MIT) From f71f797554eae0cebc3b670ce21839163d39234e Mon Sep 17 00:00:00 2001 From: Gus Date: Fri, 17 May 2024 18:25:02 -0400 Subject: [PATCH 4/4] chore: update changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c52420179..2f850bb076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 6.12.1 / 2024-05-17 + +## What's Changed +* Hotfix if the subnet UID is not in the Subnets + + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.12.0...fd2442db8bb8aad55ced2ac3b748b04ebdc73292 + + ## 6.12.0 / 2024-04-29