bt.metagraph

Chain State Torch Interface


Introduction

The Metagraph class holds the chain state of a particular subnetwork at a specific block.

Examples

1import bittensor as bt
2
3# Creating metagraph and sync state from a netuid parameter, defaults to connecting to network `finney`
4metagraph = bt.metagraph( netuid = 1 )
5
6# Create metagraph and sync with lite = False to sync weights and bonds matrices.
7metagraph = bt.metagraph( netuid = 1, lite = False)
8
9# Create metagraph and sync state from local entrypoint, assuming a subtensor chain is currently running.
10metagraph = bt.metagraph( netuid = 1, network = 'local' )
11
12# Create an empty metagraph object with no state syncing.
13metagraph = bt.metagraph( netuid = 1, sync = False )
14
15# Sync the metagraph at a particular block
16metagraph.sync( block = 100000 )
17
18# Save the metagraph to ~/.bittensor/metagraphs/network-$NETWORK_NAME/netuid-#NETUID/block-$BLOCK.pt
19metagraph.save()
20
21# Load the latest metagraph by block.
22metagraph.load()

Methods


S

1def S(self) -> torch.FloatTensor

Returns the total stake.


R

1def R(self) -> torch.FloatTensor

Returns the ranks.


I

1def I(self) -> torch.FloatTensor

Returns the incentive.


E

1def E(self) -> torch.FloatTensor

Returns the emission.


C

1def C(self) -> torch.FloatTensor

Returns the consensus.


T

1def T(self) -> torch.FloatTensor

Returns the trust.


Tv

1def Tv(self) -> torch.FloatTensor

Returns the validator trust.


D

1def D(self) -> torch.FloatTensor

Returns the dividends.


B

1def B(self) -> torch.FloatTensor

Returns the bonds.


W

1def W(self) -> torch.FloatTensor

Returns the weights.


hotkeys

1def hotkeys(self) -> List[str]

Returns the list of hotkeys for the axons.


coldkeys

1def coldkeys(self) -> List[str]

Returns the list of coldkeys for the axons.


addresses

1def addresses(self) -> List[str]

Returns the list of IP addresses for the axons.


str

1def __str__(self)

Returns a string representation of the Metagraph.


repr

1def __repr__(self)

Returns the same string representation as __str__.


metadata

1def metadata(self) -> dict

Returns a dictionary of Metagraph metadata.


init

1def __init__(self, netuid: int, network: str = 'finney', lite: bool = True, sync: bool = True) -> 'metagraph'

Initializes a new instance of the Metagraph.


sync

1def sync (self, block: Optional[int] = None, lite: bool = True) -> 'metagraph'

Syncs the Metagraph state at the passed block. Optionally syncs the weights also.


save

1def save(self) -> 'metagraph'

Saves the Metagraph object's state_dict under bittensor root directory.


load

1def load(self) -> 'metagraph'

Loads the Metagraph object's state_dict from bittensor root directory.


load_from_path

1def load_from_path(self, dir_path:str) -> 'metagraph'

Loads the Metagraph object's state_dict from the specified directory path.