The Metagraph
class holds the chain state of a particular subnetwork at a specific block.
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()
1def S(self) -> torch.FloatTensor
Returns the total stake.
1def R(self) -> torch.FloatTensor
Returns the ranks.
1def I(self) -> torch.FloatTensor
Returns the incentive.
1def E(self) -> torch.FloatTensor
Returns the emission.
1def C(self) -> torch.FloatTensor
Returns the consensus.
1def T(self) -> torch.FloatTensor
Returns the trust.
1def Tv(self) -> torch.FloatTensor
Returns the validator trust.
1def D(self) -> torch.FloatTensor
Returns the dividends.
1def B(self) -> torch.FloatTensor
Returns the bonds.
1def W(self) -> torch.FloatTensor
Returns the weights.
1def hotkeys(self) -> List[str]
Returns the list of hotkeys for the axons.
1def coldkeys(self) -> List[str]
Returns the list of coldkeys for the axons.
1def addresses(self) -> List[str]
Returns the list of IP addresses for the axons.
1def __str__(self)
Returns a string representation of the Metagraph.
1def __repr__(self)
Returns the same string representation as __str__
.
1def metadata(self) -> dict
Returns a dictionary of Metagraph metadata.
1def __init__(self, netuid: int, network: str = 'finney', lite: bool = True, sync: bool = True) -> 'metagraph'
Initializes a new instance of the Metagraph.
1def sync (self, block: Optional[int] = None, lite: bool = True) -> 'metagraph'
Syncs the Metagraph state at the passed block. Optionally syncs the weights also.
1def save(self) -> 'metagraph'
Saves the Metagraph object's state_dict under bittensor root directory.
1def load(self) -> 'metagraph'
Loads the Metagraph object's state_dict from bittensor root directory.
1def load_from_path(self, dir_path:str) -> 'metagraph'
Loads the Metagraph object's state_dict from the specified directory path.