Skip to content

Commit

Permalink
Merge pull request #2575 from opentensor/feat/roman/additionals
Browse files Browse the repository at this point in the history
[SDK] Small improvements
  • Loading branch information
roman-opentensor authored Jan 13, 2025
2 parents 110a281 + 5423311 commit 909a13c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions bittensor/core/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 of the env var `USE_TORCH`
"""

def __init__(
Expand Down
25 changes: 25 additions & 0 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -381,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":
Expand All @@ -389,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),
Expand Down
2 changes: 0 additions & 2 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 909a13c

Please sign in to comment.