Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
import os
|
4 |
|
5 |
import gradio as gr
|
|
|
6 |
from gradio_calendar import Calendar
|
7 |
|
8 |
from papers import PaperList, get_df
|
@@ -18,6 +19,11 @@ if (SPACE_ID := os.getenv("SPACE_ID")) is not None:
|
|
18 |
scheduler = UpdateScheduler(space_id=SPACE_ID, cron_hour=CRON_HOUR, cron_minute=CRON_MINUTE)
|
19 |
scheduler.start()
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Blocks(css="style.css") as demo:
|
22 |
gr.Markdown(DESCRIPTION)
|
23 |
with gr.Group():
|
@@ -25,6 +31,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
25 |
start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
|
26 |
end_date = Calendar(label="End date", type="datetime")
|
27 |
search_title = gr.Textbox(label="Search by title")
|
|
|
|
|
28 |
df = gr.Dataframe(
|
29 |
value=paper_list.df_prettified,
|
30 |
datatype=paper_list.column_datatype,
|
@@ -42,6 +50,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
42 |
inputs=[start_date, end_date, search_title],
|
43 |
outputs=df,
|
44 |
api_name=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
)
|
46 |
|
47 |
if __name__ == "__main__":
|
|
|
3 |
import os
|
4 |
|
5 |
import gradio as gr
|
6 |
+
import pandas as pd
|
7 |
from gradio_calendar import Calendar
|
8 |
|
9 |
from papers import PaperList, get_df
|
|
|
19 |
scheduler = UpdateScheduler(space_id=SPACE_ID, cron_hour=CRON_HOUR, cron_minute=CRON_MINUTE)
|
20 |
scheduler.start()
|
21 |
|
22 |
+
|
23 |
+
def update_num_papers(df: pd.DataFrame) -> str:
|
24 |
+
return f"{len(df)} / {len(paper_list.df_raw)}"
|
25 |
+
|
26 |
+
|
27 |
with gr.Blocks(css="style.css") as demo:
|
28 |
gr.Markdown(DESCRIPTION)
|
29 |
with gr.Group():
|
|
|
31 |
start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
|
32 |
end_date = Calendar(label="End date", type="datetime")
|
33 |
search_title = gr.Textbox(label="Search by title")
|
34 |
+
|
35 |
+
num_papers = gr.Textbox(label="Number of papers", value=update_num_papers(paper_list.df_raw), interactive=False)
|
36 |
df = gr.Dataframe(
|
37 |
value=paper_list.df_prettified,
|
38 |
datatype=paper_list.column_datatype,
|
|
|
50 |
inputs=[start_date, end_date, search_title],
|
51 |
outputs=df,
|
52 |
api_name=False,
|
53 |
+
).then(
|
54 |
+
fn=update_num_papers,
|
55 |
+
inputs=df,
|
56 |
+
outputs=num_papers,
|
57 |
+
queue=False,
|
58 |
+
api_name=False,
|
59 |
)
|
60 |
|
61 |
if __name__ == "__main__":
|