import gradio as gr from chain_data import sync_metagraph from leaderboard import create_leaderboard, create_dropdown from validator_states import create_validator_states from validator_weights import create_weights from wandb_data import sync def main(): sync_metagraph(timeout=1000) sync(timeout=1000) with gr.Blocks(css=".typewriter {font-family: 'JMH Typewriter', sans-serif;}", fill_height=True, fill_width=True) as app: with gr.Tab("Leaderboard") as leaderboard_tab: dropdown = gr.Dropdown() dropdown.attach_load_event(lambda: create_dropdown(), None) leaderboard_dataframe = gr.Dataframe() leaderboard_dataframe.attach_load_event(lambda uid: create_leaderboard(uid), None, inputs=[dropdown]) leaderboard_tab.select(lambda uid: create_leaderboard(uid), inputs=[dropdown], outputs=[leaderboard_dataframe]) dropdown.change(lambda uid: create_leaderboard(uid), inputs=[dropdown], outputs=[leaderboard_dataframe]) with gr.Tab("Validator States") as validator_states_tab: validator_states_dataframe = gr.Dataframe() validator_states_dataframe.attach_load_event(lambda: create_validator_states(), None) validator_states_tab.select(lambda: create_validator_states(), [], [validator_states_dataframe]) with gr.Tab("Validator Weights") as validator_weights_tab: include_inactive_checkbox = gr.Checkbox(False,label="Include Inactive", container=False,) validator_weights_dataframe = gr.Dataframe() validator_weights_dataframe.attach_load_event(lambda include_inactive: create_weights(include_inactive), None, [include_inactive_checkbox]) validator_weights_tab.select(lambda include_inactive: create_weights(include_inactive), [include_inactive_checkbox], [validator_weights_dataframe]) include_inactive_checkbox.change(lambda include_inactive: create_weights(include_inactive), [include_inactive_checkbox], [validator_weights_dataframe]) with gr.Tab("Model Demo"): gr.Label("Coming soon!", show_label=False) app.launch() if __name__ == "__main__": main()