import gradio as gr import pandas as pd import matplotlib.pyplot as plt from dataset_util import load_data, get_num_rows import subnet_util import datetime import typing import indexing_util import weights from io import BytesIO FONT = """""" TITLE_FONT = """""" TITLE = """
"""
last_refresh = None
demo = gr.Blocks(css="""
.intersect {font-family: 'Intersect C BRK', sans-serif; font-size:40px}
.promova {font-family: 'Promova', sans-serif; font-size:40px}
""")
twitter_text_dataset = load_data("bittensor-dataset/twitter-text-dataset")
twitter_text_num_rows = get_num_rows(twitter_text_dataset)
twitter_image_dataset = load_data("bittensor-dataset/twitter-image-dataset")
twitter_image_num_rows = get_num_rows(twitter_image_dataset)
tao_price = subnet_util.get_tao_price()
(subtensor, metagraph) = subnet_util.get_subtensor_and_metagraph()
last_refresh = datetime.datetime.now()
miners_data = subnet_util.get_subnet_data(subtensor, metagraph)
# url = "http://127.0.0.1:8001/"
# try:
# response = requests.get(url)
# response_body = response.json()
# twitter_text_num_rows = response_body['twitter_text_rows']
# twitter_image_num_rows = response_body['twitter_image_rows']
# except:
# twitter_text_num_rows = 0
# twitter_image_num_rows = 0
# bt.logging.error("Could not connect to the API")
daily_indexing_data = indexing_util.get_all(indexing_util.daily_indexing)
daily_df = pd.DataFrame(daily_indexing_data, columns=['Date', 'Value'])
daily_df['Date'] = pd.to_datetime(daily_df['Date'].str.decode('utf-8'))
daily_df['Value'] = daily_df['Value'].astype(int)
hotkey_indexing_data = indexing_util.get_all(indexing_util.hotkey_indexing)
hotkey_df = pd.DataFrame(hotkey_indexing_data, columns=['Hotkey', 'Value'])
hotkey_df['Hotkey'] = hotkey_df['Hotkey'].str.decode('utf-8')
hotkey_df['Value'] = hotkey_df['Value'].astype(int)
# Filter hotkey_df to only show value is over than 1000
hotkey_df = hotkey_df[hotkey_df['Value'] > 1000]
# Sort hotkey_df by Value
hotkey_df = hotkey_df.sort_values(by='Value', ascending=False)
hotkey_daily_indexing_data = indexing_util.get_all(indexing_util.hotkey_daily_indexing)
hotkey_daily_df = pd.DataFrame(hotkey_daily_indexing_data, columns=['Hotkey_Date', 'Value'])
hotkey_daily_df_= pd.DataFrame()
hotkey_daily_df_['Hotkey'] = hotkey_daily_df['Hotkey_Date'].str.decode('utf-8').str.split(' ').str[0]
hotkey_daily_df_['Date'] = hotkey_daily_df['Hotkey_Date'].str.decode('utf-8').str.split(' ').str[1]
hotkey_daily_df_['Value'] = hotkey_daily_df['Value'].astype(int)
dalily_df_max = daily_df['Value'].max()
hotkey_df_max = hotkey_df['Value'].max()
hotkey_daily_df_max = hotkey_daily_df_['Value'].max()
# print(hotkey_daily_df_)
weight_list, miners = weights.validator_info()
print(weight_list)
def leaderboard_data(
# show_stale: bool,
# scores: typing.Dict[int, typing.Dict[str, typing.Optional[float | str]]],
# competition_id: str,
):
value = [
[
c.hotkey[0:8] + "...",
c.uid,
c.url,
c.block,
]
for c in miners_data
# if c.incentive and c.url[0:8] == "https://"
]
return value
def validator_data():
value = [
[
c['uid'],
"{:,}".format(c['validator_stake']) + " τ",
c['vtrust'],
] + [
c ['miners_weight'].get(miner[0], 0)
for miner in miners
]
for c in weight_list
]
return value
with demo:
gr.HTML(FONT)
gr.HTML(TITLE_FONT)
gr.HTML(TITLE)
gr.HTML(IMAGE)
gr.HTML(DESCRIPTION)
with gr.Tabs():
with gr.Accordion("Dataset Stats"):
with gr.Row():
with gr.Column(scale=1):
gr.HTML(f"