Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Add filter by date
Browse files
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: π
|
|
4 |
colorFrom: pink
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
4 |
colorFrom: pink
|
5 |
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.14.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
import os
|
4 |
|
5 |
import gradio as gr
|
|
|
6 |
|
7 |
from papers import PaperList, get_df
|
8 |
from update_scheduler import UpdateScheduler
|
@@ -19,6 +20,10 @@ if (SPACE_ID := os.getenv("SPACE_ID")) is not None:
|
|
19 |
|
20 |
with gr.Blocks(css="style.css") as demo:
|
21 |
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
22 |
df = gr.Dataframe(
|
23 |
value=paper_list.df_prettified,
|
24 |
datatype=paper_list.column_datatype,
|
@@ -30,5 +35,13 @@ with gr.Blocks(css="style.css") as demo:
|
|
30 |
wrap=True,
|
31 |
)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
if __name__ == "__main__":
|
34 |
demo.queue(api_open=False).launch()
|
|
|
3 |
import os
|
4 |
|
5 |
import gradio as gr
|
6 |
+
from gradio_calendar import Calendar
|
7 |
|
8 |
from papers import PaperList, get_df
|
9 |
from update_scheduler import UpdateScheduler
|
|
|
20 |
|
21 |
with gr.Blocks(css="style.css") as demo:
|
22 |
gr.Markdown(DESCRIPTION)
|
23 |
+
with gr.Group():
|
24 |
+
with gr.Row():
|
25 |
+
start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
|
26 |
+
end_date = Calendar(label="End date", type="datetime")
|
27 |
df = gr.Dataframe(
|
28 |
value=paper_list.df_prettified,
|
29 |
datatype=paper_list.column_datatype,
|
|
|
35 |
wrap=True,
|
36 |
)
|
37 |
|
38 |
+
gr.on(
|
39 |
+
triggers=[start_date.change, end_date.change],
|
40 |
+
fn=paper_list.filter_by_date,
|
41 |
+
inputs=[start_date, end_date],
|
42 |
+
outputs=df,
|
43 |
+
api_name=False,
|
44 |
+
)
|
45 |
+
|
46 |
if __name__ == "__main__":
|
47 |
demo.queue(api_open=False).launch()
|
papers.py
CHANGED
@@ -97,3 +97,11 @@ class PaperList:
|
|
97 |
@property
|
98 |
def column_datatype(self):
|
99 |
return list(map(operator.itemgetter(1), self.COLUMN_INFO))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
@property
|
98 |
def column_datatype(self):
|
99 |
return list(map(operator.itemgetter(1), self.COLUMN_INFO))
|
100 |
+
|
101 |
+
def filter_by_date(self, start_date: datetime.datetime, end_date: datetime.datetime) -> pd.DataFrame:
|
102 |
+
df = self.df_raw.copy()
|
103 |
+
df["date"] = pd.to_datetime(df["date"])
|
104 |
+
df = df[(df["date"] >= start_date) & (df["date"] <= end_date)]
|
105 |
+
df["date"] = df["date"].dt.strftime("%Y-%m-%d")
|
106 |
+
df_prettified = self._prettifier(df).loc[:, self.column_names]
|
107 |
+
return df_prettified
|
requirements.txt
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
apscheduler==3.10.4
|
2 |
-
gradio==4.
|
|
|
3 |
huggingface_hub==0.20.2
|
4 |
pandas==2.1.4
|
5 |
requests==2.31.0
|
|
|
1 |
apscheduler==3.10.4
|
2 |
+
gradio==4.14.0
|
3 |
+
gradio_calendar==0.0.2
|
4 |
huggingface_hub==0.20.2
|
5 |
pandas==2.1.4
|
6 |
requests==2.31.0
|