#!/usr/bin/env python import os import gradio as gr from gradio_calendar import Calendar from papers import PaperList, get_df from update_scheduler import UpdateScheduler DESCRIPTION = "# [Daily Papers](https://huggingface.co/papers)" paper_list = PaperList(get_df("papers.csv")) if (SPACE_ID := os.getenv("SPACE_ID")) is not None: CRON_HOUR = os.getenv("CRON_HOUR", "*/4") CRON_MINUTE = os.getenv("CRON_MINUTE", "0") scheduler = UpdateScheduler(space_id=SPACE_ID, cron_hour=CRON_HOUR, cron_minute=CRON_MINUTE) scheduler.start() with gr.Blocks(css="style.css") as demo: gr.Markdown(DESCRIPTION) with gr.Group(): with gr.Row(): start_date = Calendar(label="Start date", type="datetime", value="2023-05-05") end_date = Calendar(label="End date", type="datetime") df = gr.Dataframe( value=paper_list.df_prettified, datatype=paper_list.column_datatype, type="pandas", interactive=False, height=1000, elem_id="table", column_widths=["10%", "10%", "60%", "10%", "10%"], wrap=True, ) gr.on( triggers=[start_date.change, end_date.change], fn=paper_list.filter_by_date, inputs=[start_date, end_date], outputs=df, api_name=False, ) if __name__ == "__main__": demo.queue(api_open=False).launch()