Spaces:
Running
Running
import gradio as gr | |
import pandas as pd | |
from chain_data import sync_metagraph, COMMITMENTS, UIDS_BY_HOTKEY | |
from wandb_data import get_current_runs, Run, Uid | |
def get_status(run: Run, uid: Uid, block: int) -> tuple[str, str]: | |
if all(not submission.get(uid) or block > submission[uid].info.block for submission in [run.submissions, run.invalid_submissions]): | |
return "Pending", "orange" | |
if uid in run.submissions: | |
return "Benchmarked", "springgreen" | |
elif uid in run.invalid_submissions: | |
return "Invalid", "red" | |
else: | |
return "Pending", "orange" | |
def create_submissions() -> gr.Dataframe: | |
data: list[list] = [] | |
sync_metagraph() | |
runs = sorted(get_current_runs(), key=lambda run: run.uid) | |
for hotkey, commitment in COMMITMENTS.items(): | |
uid = UIDS_BY_HOTKEY[hotkey] | |
row = [ | |
uid, | |
f"[{'/'.join(commitment.get_repo_link().split('/')[-2:])}]({commitment.get_repo_link()})", | |
f"[{commitment.block}](https://taostats.io/block/{commitment.block})", | |
f"[{commitment.revision}]({commitment.get_repo_link()}/commit/{commitment.revision})", | |
f"[{hotkey[:6]}...](https://taostats.io/hotkey/{hotkey})", | |
commitment.contest.name, | |
] | |
for run in runs: | |
status, color = get_status(run, uid, commitment.block) | |
row.append(f"<span style='color: {color}'>{status}</span>") | |
data.append(row) | |
data.sort(key=lambda x: int(x[2].split('[')[1].split(']')[0]), reverse=True) | |
columns = ["UID", "Model", "Block", "Revision", "Hotkey", "Contest"] | |
datatype = ["number", "markdown", "markdown", "markdown", "markdown", "markdown"] | |
for run in runs: | |
columns.append(f"{run.uid}") | |
datatype.append("markdown") | |
return gr.Dataframe( | |
pd.DataFrame(data, columns=columns), | |
datatype=datatype, | |
interactive=False, | |
max_height=800, | |
) | |