seawolf2357 commited on
Commit
9920acf
·
verified ·
1 Parent(s): 7de46c8

Delete app-backup.py

Browse files
Files changed (1) hide show
  1. app-backup.py +0 -114
app-backup.py DELETED
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import datetime
4
-
5
- import gradio as gr
6
- import pandas as pd
7
- from apscheduler.schedulers.background import BackgroundScheduler
8
- from gradio_calendar import Calendar
9
-
10
- from papers import PaperList, get_df
11
-
12
- DESCRIPTION = "# [Papers Leaderboard](https://huggingface.co/papers)"
13
-
14
- FOOT_NOTE = """\
15
- Community: https://discord.gg/openfreeai
16
- """
17
-
18
-
19
- paper_list = PaperList(get_df())
20
-
21
-
22
- def update_paper_list() -> None:
23
- global paper_list # noqa: PLW0603
24
- paper_list = PaperList(get_df())
25
-
26
-
27
- scheduler = BackgroundScheduler()
28
- scheduler.add_job(func=update_paper_list, trigger="cron", hour="*", timezone="UTC", misfire_grace_time=60)
29
- scheduler.start()
30
-
31
-
32
- def update_df() -> gr.Dataframe:
33
- return gr.Dataframe(value=paper_list.df_prettified)
34
-
35
-
36
- def update_num_papers(df: pd.DataFrame) -> str:
37
- return f"{len(df)} / {len(paper_list.df_raw)}"
38
-
39
-
40
- def search(
41
- start_date: datetime.datetime,
42
- end_date: datetime.datetime,
43
- search_title: str,
44
- search_abstract: str,
45
- max_num_to_retrieve: int,
46
- ) -> pd.DataFrame:
47
- return paper_list.search(start_date, end_date, search_title, search_abstract, max_num_to_retrieve)
48
-
49
-
50
- with gr.Blocks(css_paths="style.css") as demo:
51
- gr.Markdown(DESCRIPTION)
52
- with gr.Group():
53
- search_title = gr.Textbox(label="Search title")
54
- with gr.Row():
55
- with gr.Column(scale=4):
56
- search_abstract = gr.Textbox(
57
- label="Search abstract",
58
- info="The result may not be accurate as the abstract does not contain all the information.",
59
- )
60
- with gr.Column(scale=1):
61
- max_num_to_retrieve = gr.Slider(
62
- label="Max number to retrieve",
63
- info="This is used only for search on abstracts.",
64
- minimum=1,
65
- maximum=len(paper_list.df_raw),
66
- step=1,
67
- value=100,
68
- )
69
- with gr.Row():
70
- start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
71
- end_date = Calendar(label="End date", type="datetime")
72
-
73
- num_papers = gr.Textbox(label="Number of papers", value=update_num_papers(paper_list.df_raw), interactive=False)
74
- df = gr.Dataframe(
75
- value=paper_list.df_prettified,
76
- datatype=paper_list.column_datatype,
77
- type="pandas",
78
- interactive=False,
79
- max_height=1000,
80
- elem_id="table",
81
- column_widths=["10%", "10%", "60%", "10%", "5%", "5%"],
82
- wrap=True,
83
- )
84
-
85
- gr.Markdown(FOOT_NOTE)
86
-
87
- gr.on(
88
- triggers=[start_date.change, end_date.change, search_title.submit, search_abstract.submit],
89
- fn=search,
90
- inputs=[start_date, end_date, search_title, search_abstract, max_num_to_retrieve],
91
- outputs=df,
92
- api_name=False,
93
- ).then(
94
- fn=update_num_papers,
95
- inputs=df,
96
- outputs=num_papers,
97
- queue=False,
98
- api_name=False,
99
- )
100
- demo.load(
101
- fn=update_df,
102
- outputs=df,
103
- queue=False,
104
- api_name=False,
105
- ).then(
106
- fn=update_num_papers,
107
- inputs=df,
108
- outputs=num_papers,
109
- queue=False,
110
- api_name=False,
111
- )
112
-
113
- if __name__ == "__main__":
114
- demo.queue(api_open=False).launch(show_api=False)