From 8c2a01f9eb05cb77c8f4a973bbe9a9342dc95ddd Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 21 Mar 2023 19:23:21 -0400 Subject: [PATCH 1/2] fix typehints --- bittensor/_cli/commands/overview.py | 4 ++-- bittensor/_endpoint/__init__.py | 4 ++-- bittensor/_metagraph/__init__.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bittensor/_cli/commands/overview.py b/bittensor/_cli/commands/overview.py index 9324210352..99490d5927 100644 --- a/bittensor/_cli/commands/overview.py +++ b/bittensor/_cli/commands/overview.py @@ -73,7 +73,7 @@ def run( cli ): return # Pull neuron info for all keys. - neurons: Dict[str, List[bittensor.NeuronInfo, bittensor.Wallet]] = {} + neurons: Dict[str, List[bittensor.NeuronInfoLite, bittensor.Wallet]] = {} block = subtensor.block netuids = subtensor.get_all_subnet_netuids() @@ -127,7 +127,7 @@ def run( cli ): total_emission = 0 for nn, hotwallet in neurons[str(netuid)]: - nn: bittensor.NeuronInfo + nn: bittensor.NeuronInfoLite uid = nn.uid active = nn.active stake = nn.total_stake.tao diff --git a/bittensor/_endpoint/__init__.py b/bittensor/_endpoint/__init__.py index 8de7747455..2d21d04f4b 100644 --- a/bittensor/_endpoint/__init__.py +++ b/bittensor/_endpoint/__init__.py @@ -18,7 +18,7 @@ # DEALINGS IN THE SOFTWARE. import json -from types import SimpleNamespace +from typing import Union import torch import bittensor @@ -63,7 +63,7 @@ def __new__( @staticmethod - def from_neuron( neuron: 'bittensor.NeuronInfo' ) -> 'bittensor.Endpoint': + def from_neuron( neuron: Union['bittensor.NeuronInfo', 'bittensor.NeuronInfoLite'] ) -> 'bittensor.Endpoint': """ endpoint.assert_format( version = neuron.version, diff --git a/bittensor/_metagraph/__init__.py b/bittensor/_metagraph/__init__.py index 9f8bbd6a8d..435affc954 100644 --- a/bittensor/_metagraph/__init__.py +++ b/bittensor/_metagraph/__init__.py @@ -132,7 +132,7 @@ def from_neurons( network: str, netuid: int, info: 'bittensor.SubnetInfo', neuro netuid of the subnet for the metagraph. info: (:obj:`SubnetInfo`, required): SubnetInfo object for the metagraph, including the subnet's hyperparameters. - neurons: (:obj:`List[NeuronInfo]`, required): + neurons: (:obj:`Union[List[NeuronInfo], List[NeuronInfoLite]]`, required): List of neurons to create metagraph from. block: (:obj:`int`, required): Block number at time of the metagraph. From cae67e15f10dc548a8f91da89d8128e7a2cc131e Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 21 Mar 2023 19:23:29 -0400 Subject: [PATCH 2/2] don't count zero nominators --- bittensor/_cli/commands/delegates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/_cli/commands/delegates.py b/bittensor/_cli/commands/delegates.py index 2bb257410d..e1e7f377db 100644 --- a/bittensor/_cli/commands/delegates.py +++ b/bittensor/_cli/commands/delegates.py @@ -112,7 +112,7 @@ def show_delegates( delegates: List['bittensor.DelegateInfo'], prev_delegates: L str(i), Text(delegate_name, style=f'link {delegate_url}'), f'{delegate.hotkey_ss58:8.8}...', - str(len(delegate.nominators)), + str(len([nom for nom in delegate.nominators if nom[1].rao > 0])), f'{owner_stake!s:13.13}', f'{delegate.total_stake!s:13.13}', rate_change_in_stake_str,