opentensor / btcli

Bittensor command line tool
https://docs.bittensor.com/btcli
13 stars 3 forks source link

Discuss dict responses for btcli commands #136

Closed thewhaleking closed 1 month ago

thewhaleking commented 1 month ago

Question by @sirouk in Church of Rao:

Hey, could anyone point me in the right direction for emulating the same data from subnet s list with python? I used to screen scrape subnet s list and then augment some additional data like subnet weight. However, I seem to have an issue getting the right values for subnet emission. Here's what I have so far:

import bittensor as bt
import pandas as pd

subtensor_address = "127.0.0.1:9944"
subtensor = bt.subtensor(network=f"ws://{subtensor_address}")

subnets_data = []
for netuid in subtensor.get_subnets():
    subnet = subtensor.metagraph(netuid)
    data = {
    'NETUID': subnet.netuid,
    'N': subnet.n,
    'MAX_N': len(subnet.neurons),
    'EMISSION': subnet.emission,
    'TEMPO': subnet.block,
    'BURN': subnet.bonds,
    'POW': f"{sum(subnet.consensus) * 1e6:.2f} T",
    'SUDO': ', '.join(subnet.hotkeys),
    'WEIGHT': sum(subnet.emission),
    }
    subnets_data.append(data)

    print(f"Processed subnet NETUID: {data['NETUID']}")

subnet_df = pd.DataFrame(subnets_data)

print(subnet_df)

I used to grab weight for the subnet like so: float(subtensor.get_emission_value_by_subnet(netuid=subnet_id) get_emission_value_by_subnet() seems to be depreciated

When initially designing the new btcli, we wanted it to be basically standalone and not be used for scripts or an SDK, but it would be fairly trivial to add response data in a dict/list/bool for each of the commands, so the response data could be used in scripts.

thewhaleking commented 1 month ago

No.