import gradio as gr from apscheduler.schedulers.background import BackgroundScheduler from src.static.env import API, REPO_ID, HF_TOKEN from src.static.about import TITLE, INTRO, ABOUT from src.leaderboards.get_from_hub import get_leaderboard_info def restart_space(): API.restart_space(repo_id=REPO_ID, token=HF_TOKEN) leaderboards_to_info, info_to_leaderboards = get_leaderboard_info() demo = gr.Blocks() with demo: gr.HTML(TITLE) gr.Markdown(INTRO, elem_classes="markdown-text") with gr.Tabs(elem_classes="tab-buttons") as tabs: with gr.TabItem("Search"): gr.Markdown("Let's look for leaderboards relevant for you! Select the categories of your choice") with gr.TabItem("About"): gr.Markdown(ABOUT, elem_classes="markdown-text") scheduler = BackgroundScheduler() scheduler.add_job(restart_space, "interval", seconds=10800) # restarted every 3h scheduler.start() demo.queue(default_concurrency_limit=40).launch()