Skip to content

Commit

Permalink
Fix metagraph output (#1116)
Browse files Browse the repository at this point in the history
* fix symbol unicode

* add alias for --delegate_ss58

* fix patch

* add linux bin

* .

* nominate test works

* delegate stake works

* delegate unstake works

* remove todo

* fix mock of get all hotkeys

* use finney for network name and _mock for config

* fix add arg

* add rich text console helpers

* overview test for subnets

* add case for overview

* add overview test for unregistered subnet 1 and 2

* add transfer test

* add test for failed transfer

* transfer test with check for error output

* fix metagraph output and add test
  • Loading branch information
camfairchild authored Mar 9, 2023
1 parent 466956b commit 1cca2a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bittensor/_cli/commands/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run (cli):
ep = metagraph.endpoint_objs[uid]
row = [
str(ep.uid),
'{:.5f}'.format( metagraph.stake[uid]),
'{:.5f}'.format( metagraph.total_stake[uid]),
'{:.5f}'.format( metagraph.ranks[uid]),
'{:.5f}'.format( metagraph.trust[uid]),
'{:.5f}'.format( metagraph.consensus[uid]),
Expand All @@ -66,7 +66,7 @@ def run (cli):
ep.hotkey[:10],
ep.coldkey[:10]
]
total_stake += metagraph.stake[uid]
total_stake += metagraph.total_stake[uid]
total_rank += metagraph.ranks[uid]
# total_validator_trust += metagraph.validator_trust[uid]
total_trust += metagraph.trust[uid]
Expand Down
36 changes: 35 additions & 1 deletion tests/integration_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,9 +1897,43 @@ def test_metagraph( self ):
config.command = "metagraph"
config.no_prompt = True

# Add some neurons to the metagraph
mock_nn = []
for i in range(10):
mock_nn.append(
SimpleNamespace(
hotkey = get_mock_keypair(i + 100, self.id()).ss58_address,
coldkey = get_mock_keypair(i, self.id()).ss58_address,
balance = Balance.from_rao( random.randint(0, 2**45) ).rao,
stake = Balance.from_rao( random.randint(0, 2**45) ).rao,
)
)
success, err = _subtensor_mock.sudo_register(
netuid = config.netuid,
hotkey = mock_nn[i].hotkey,
coldkey = mock_nn[i].coldkey,
balance = mock_nn[i].balance,
stake = mock_nn[i].stake
)
self.assertTrue(success, err)

cli = bittensor.cli(config)
cli.run()

mock_console = MockConsole()
with patch('bittensor.__console__', mock_console):
cli.run()

# Check that the overview was printed.
self.assertIsNotNone(mock_console.captured_print)

output_no_syntax = mock_console.remove_rich_syntax(mock_console.captured_print)

self.assertIn('Metagraph', output_no_syntax)
nn = _subtensor_mock.neurons( netuid = config.netuid )
self.assertIn(str(len(nn) - 1), output_no_syntax) # Check that the number of neurons is output
# Check each uid is in the output
for neuron in nn:
self.assertIn(str(neuron.uid), output_no_syntax)

def test_set_weights( self ):

Expand Down

0 comments on commit 1cca2a9

Please sign in to comment.