Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix metagraph object on text_prompting #1318

Merged
merged 4 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bittensor/_metagraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def __init__(self, netuid: int, network: str = 'finney', lite: bool = True, sync
if sync:
self.sync( block = None, lite = lite )

def sync ( self, block: Optional[int] = None, lite: bool = True ) -> 'metagraph':
subtensor = bittensor.subtensor( network = self.network )
def sync ( self, block: Optional[int] = None, lite: bool = True, subtensor: Optional['bittensor.Subtensor'] = None ) -> 'metagraph':
if not subtensor:
subtensor = bittensor.subtensor( network = self.network )
if lite:
self.neurons = subtensor.neurons_lite( block = block, netuid = self.netuid )
else:
Expand Down
16 changes: 7 additions & 9 deletions bittensor/_subtensor/subtensor_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,25 +945,23 @@ def make_substrate_call_with_retry():

return NeuronInfoLite.list_from_vec_u8( result )

def metagraph( self, netuid: int, lite: bool = True ) -> 'bittensor.Metagraph':
def metagraph( self, netuid: int, lite: bool = True, block: Optional[int] = None ) -> 'bittensor.Metagraph':
r""" Returns the metagraph for the subnet.
Args:
netuid ( int ):
The network uid of the subnet to query.
lite (bool, default=True):
If true, returns a metagraph using the lite sync (no weights, no bonds)
block ( Optional[int] ):
block to sync from, or None for latest block.
Returns:
metagraph ( `bittensor.Metagraph` ):
The metagraph for the subnet at the block.
"""
return bittensor.metagraph( network = self.network, netuid = netuid, lite = lite )

################
#### Transfer ##
################


"""
metagraph_ = bittensor.metagraph( network = self.network, netuid = netuid, lite = lite, sync = False )
metagraph_.sync( block = block, lite = lite, subtensor = self)

return metagraph_

################
#### Legacy ####
Expand Down