opentensor / bittensor

Internet-scale Neural Networks
https://www.bittensor.com/
MIT License
886 stars 306 forks source link

Metagraph async #1994

Closed ibraheem-opentensor closed 3 months ago

ibraheem-opentensor commented 3 months ago

Async migration for the following modules:

thewhaleking commented 3 months ago

@ibraheem-opentensor hey I didn't get a chance to review this, but let's update this:

difficulty = await subtensor.difficulty(cli.config.netuid)
subnet_emission = bittensor.Balance.from_tao(
    await subtensor.get_emission_value_by_subnet(cli.config.netuid)
)
total_issuance = bittensor.Balance.from_rao(
    (await subtensor.total_issuance()).rao
)

to

difficulty, subnet_emission_, total_issuance_ = await asyncio.gather(
    subtensor.difficulty(cli.config.netuid),
    subtensor.get_emission_value_by_subnet(cli.config.netuid),
    subtensor.total_issuance()
)
subnet_emission = bittensor.Balance.from_tao(subnet_emission_)
total_issuance = bittensor.Balance.from_rao(total_issuance_).rao

We want to take full advantage of asyncio with big push.