From d524036ed41e16e94e711839cb62cf55f9d6c0df Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 13 Jan 2025 10:12:59 -0800 Subject: [PATCH 1/5] add `bittensor.core.subtensor.Subtensor` docstring --- bittensor/core/subtensor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 653da8c2b0..6e232e1d41 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -29,6 +29,13 @@ class Subtensor: + """ + Represents a synchronous interface for `bittensor.core.async_subtensor.AsyncSubtensor`. + + If you want to get the description of any method from the `bittensor.core.subtensor.Subtensor` class, then simply + get the corresponding method from the `bittensor.core.async_subtensor.AsyncSubtensor` class. + """ + # get static methods from AsyncSubtensor config = AsyncSubtensor.config setup_config = AsyncSubtensor.setup_config From fdb03f3611b2161a4930ed323e9eaf95c7096a3e Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 13 Jan 2025 10:15:56 -0800 Subject: [PATCH 2/5] update `bittensor.core.metagraph.Metagraph` docstring --- bittensor/core/metagraph.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bittensor/core/metagraph.py b/bittensor/core/metagraph.py index b5b958b93f..e635177371 100644 --- a/bittensor/core/metagraph.py +++ b/bittensor/core/metagraph.py @@ -1493,6 +1493,11 @@ class Metagraph(AsyncMetagraph): This class provides a synchronous interface to interact with an asynchronous metagraph. It is initialized with configuration related to the network and provides methods for synchronizing and accessing asynchronous metagraph attributes. + + If you want to get the description of any method from the `bittensor.core.metagraph.Metagraph` class, then simply + get the corresponding method from the `bittensor.core.metagraph.AsyncMetagraph` class. + `AsyncMetagraph` is the class related with `AsyncTorchMetaGraph` or `AsyncNonTorchMetagraph` depending on the use + of the `use_torch(True)` or `use_torch(False)` """ def __init__( From 8c0e9bc05894cb306110914c25e35b5dfd217a66 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 13 Jan 2025 10:28:41 -0800 Subject: [PATCH 3/5] make Subtensor compatible with AsyncSubtensor --- bittensor/core/subtensor.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 6e232e1d41..152ec9a391 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -388,6 +388,15 @@ def get_total_stake_for_coldkey( ) return result + def get_total_stake_for_coldkeys( + self, *ss58_addresses: str, block: Optional[int] = None + ) -> dict[str, "Balance"]: + return self.execute_coroutine( + self.async_subtensor.get_total_stake_for_coldkeys( + *ss58_addresses, block=block + ), + ) + def get_total_stake_for_hotkey( self, ss58_address: str, block: Optional[int] = None ) -> "Balance": @@ -396,6 +405,15 @@ def get_total_stake_for_hotkey( ) return result + def get_total_stake_for_hotkeys( + self, *ss58_addresses: str, block: Optional[int] = None + ) -> dict[str, "Balance"]: + return self.execute_coroutine( + self.async_subtensor.get_total_stake_for_hotkeys( + *ss58_addresses, block=block + ), + ) + def get_total_subnets(self, block: Optional[int] = None) -> Optional[int]: return self.execute_coroutine( self.async_subtensor.get_total_subnets(block=block), From 6060cf417c989e7085dd490516c73a0f407afe64 Mon Sep 17 00:00:00 2001 From: Roman Date: Mon, 13 Jan 2025 10:28:53 -0800 Subject: [PATCH 4/5] fix test --- tests/unit_tests/test_subtensor.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index ee7d3c82b0..bdf6f9720e 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -20,8 +20,6 @@ def test_methods_comparable(mocker): "encode_params", "get_hyperparameter", "sign_and_send_extrinsic", - "get_total_stake_for_coldkeys", - "get_total_stake_for_hotkeys", ] subtensor_methods = [ m From 5423311b069e8630eddb4b6a11e5fae132dc7eb4 Mon Sep 17 00:00:00 2001 From: Roman <167799377+roman-opentensor@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:59:04 -0800 Subject: [PATCH 5/5] Update bittensor/core/metagraph.py Co-authored-by: Benjamin Himes <37844818+thewhaleking@users.noreply.github.com> --- bittensor/core/metagraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/core/metagraph.py b/bittensor/core/metagraph.py index e635177371..20c18db41c 100644 --- a/bittensor/core/metagraph.py +++ b/bittensor/core/metagraph.py @@ -1497,7 +1497,7 @@ class Metagraph(AsyncMetagraph): If you want to get the description of any method from the `bittensor.core.metagraph.Metagraph` class, then simply get the corresponding method from the `bittensor.core.metagraph.AsyncMetagraph` class. `AsyncMetagraph` is the class related with `AsyncTorchMetaGraph` or `AsyncNonTorchMetagraph` depending on the use - of the `use_torch(True)` or `use_torch(False)` + of the use of the env var `USE_TORCH` """ def __init__(