import gradio as gr from huggingface_hub import HfApi from matchmaking import * from background_task import init_matchmaking, get_elo_data from apscheduler.schedulers.background import BackgroundScheduler matchmaking = Matchmaking() api = HfApi() # launch scheduler = BackgroundScheduler() scheduler.add_job(func=init_matchmaking, trigger="interval", seconds=300) scheduler.start() def update_elos(): matchmaking.read_history() matchmaking.compute_elo() matchmaking.save_elo_data() with gr.Blocks() as block: gr.Markdown(f""" # 🏆 AI vs. AI SoccerTwos Leaderboard ⚽ In this leaderboard, you can find the ELO score and the rank of your trained model for the SoccerTwos environment. You **can click on the model's name** to be redirected to its model card page. 🤖 For more information about this AI vs. AI challenge and to participate? Check: [ADD LINK]. """) with gr.Row(): output = gr.components.Dataframe( value=get_elo_data(), headers=["Ranking 🏆", "User 🤗", "Model id 🤖", "ELO 🚀", "Games played 🎮"], datatype=["number", "markdown", "markdown", "number", "number"] ) with gr.Row(): refresh = gr.Button("Refresh") refresh.click(get_elo_data, inputs=[], outputs=output) block.launch()