hysts HF staff commited on
Commit
2e8621f
1 Parent(s): eb928c8
Files changed (6) hide show
  1. .pre-commit-config.yaml +59 -35
  2. .style.yapf +0 -5
  3. README.md +1 -1
  4. app.py +18 -18
  5. paper_list.py +46 -48
  6. style.css +1 -4
.pre-commit-config.yaml CHANGED
@@ -1,36 +1,60 @@
1
  repos:
2
- - repo: https://github.com/pre-commit/pre-commit-hooks
3
- rev: v4.2.0
4
- hooks:
5
- - id: check-executables-have-shebangs
6
- - id: check-json
7
- - id: check-merge-conflict
8
- - id: check-shebang-scripts-are-executable
9
- - id: check-toml
10
- - id: check-yaml
11
- - id: double-quote-string-fixer
12
- - id: end-of-file-fixer
13
- - id: mixed-line-ending
14
- args: ['--fix=lf']
15
- - id: requirements-txt-fixer
16
- - id: trailing-whitespace
17
- - repo: https://github.com/myint/docformatter
18
- rev: v1.4
19
- hooks:
20
- - id: docformatter
21
- args: ['--in-place']
22
- - repo: https://github.com/pycqa/isort
23
- rev: 5.12.0
24
- hooks:
25
- - id: isort
26
- - repo: https://github.com/pre-commit/mirrors-mypy
27
- rev: v0.991
28
- hooks:
29
- - id: mypy
30
- args: ['--ignore-missing-imports']
31
- additional_dependencies: ['types-requests']
32
- - repo: https://github.com/google/yapf
33
- rev: v0.32.0
34
- hooks:
35
- - id: yapf
36
- args: ['--parallel', '--in-place']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.0
4
+ hooks:
5
+ - id: check-executables-have-shebangs
6
+ - id: check-json
7
+ - id: check-merge-conflict
8
+ - id: check-shebang-scripts-are-executable
9
+ - id: check-toml
10
+ - id: check-yaml
11
+ - id: end-of-file-fixer
12
+ - id: mixed-line-ending
13
+ args: ["--fix=lf"]
14
+ - id: requirements-txt-fixer
15
+ - id: trailing-whitespace
16
+ - repo: https://github.com/myint/docformatter
17
+ rev: v1.7.5
18
+ hooks:
19
+ - id: docformatter
20
+ args: ["--in-place"]
21
+ - repo: https://github.com/pycqa/isort
22
+ rev: 5.13.2
23
+ hooks:
24
+ - id: isort
25
+ args: ["--profile", "black"]
26
+ - repo: https://github.com/pre-commit/mirrors-mypy
27
+ rev: v1.10.0
28
+ hooks:
29
+ - id: mypy
30
+ args: ["--ignore-missing-imports"]
31
+ additional_dependencies:
32
+ [
33
+ "types-python-slugify",
34
+ "types-requests",
35
+ "types-PyYAML",
36
+ "types-pytz",
37
+ ]
38
+ - repo: https://github.com/psf/black
39
+ rev: 24.4.2
40
+ hooks:
41
+ - id: black
42
+ language_version: python3.10
43
+ args: ["--line-length", "119"]
44
+ - repo: https://github.com/kynan/nbstripout
45
+ rev: 0.7.1
46
+ hooks:
47
+ - id: nbstripout
48
+ args:
49
+ [
50
+ "--extra-keys",
51
+ "metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
52
+ ]
53
+ - repo: https://github.com/nbQA-dev/nbQA
54
+ rev: 1.8.5
55
+ hooks:
56
+ - id: nbqa-black
57
+ - id: nbqa-pyupgrade
58
+ args: ["--py37-plus"]
59
+ - id: nbqa-isort
60
+ args: ["--float-to-top"]
.style.yapf DELETED
@@ -1,5 +0,0 @@
1
- [style]
2
- based_on_style = pep8
3
- blank_line_before_nested_class_or_def = false
4
- spaces_before_comment = 2
5
- split_before_logical_operator = true
 
 
 
 
 
 
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🦀
4
  colorFrom: green
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 3.36.1
8
  app_file: app.py
9
  pinned: true
10
  ---
 
4
  colorFrom: green
5
  colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 4.36.1
8
  app_file: app.py
9
  pinned: true
10
  ---
app.py CHANGED
@@ -6,34 +6,34 @@ import gradio as gr
6
 
7
  from paper_list import PaperList
8
 
9
- DESCRIPTION = '# ICML 2022 Papers'
10
- NOTES = '''
11
  - [ICML 2022](https://icml.cc/Conferences/2022/)
12
  - [Proceedings](https://proceedings.mlr.press/v162/)
13
- '''
14
 
15
  paper_list = PaperList()
16
 
17
- with gr.Blocks(css='style.css') as demo:
18
  gr.Markdown(DESCRIPTION)
19
 
20
  search_box = gr.Textbox(
21
- label='Search Title',
22
- placeholder=
23
- 'You can search for titles with regular expressions. e.g. (?<!sur)face'
24
  )
25
- case_sensitive = gr.Checkbox(label='Case Sensitive')
26
- filter_names = gr.CheckboxGroup(label='Filter',
27
- choices=[
28
- 'arXiv',
29
- 'GitHub',
30
- 'HF Space',
31
- 'HF Model',
32
- 'HF Dataset',
33
- ])
34
- search_button = gr.Button('Search')
 
 
35
 
36
- number_of_papers = gr.Textbox(label='Number of Papers Found')
37
  table = gr.HTML(show_label=False)
38
 
39
  gr.Markdown(NOTES)
 
6
 
7
  from paper_list import PaperList
8
 
9
+ DESCRIPTION = "# ICML 2022 Papers"
10
+ NOTES = """
11
  - [ICML 2022](https://icml.cc/Conferences/2022/)
12
  - [Proceedings](https://proceedings.mlr.press/v162/)
13
+ """
14
 
15
  paper_list = PaperList()
16
 
17
+ with gr.Blocks(css="style.css") as demo:
18
  gr.Markdown(DESCRIPTION)
19
 
20
  search_box = gr.Textbox(
21
+ label="Search Title", placeholder="You can search for titles with regular expressions. e.g. (?<!sur)face"
 
 
22
  )
23
+ case_sensitive = gr.Checkbox(label="Case Sensitive")
24
+ filter_names = gr.CheckboxGroup(
25
+ label="Filter",
26
+ choices=[
27
+ "arXiv",
28
+ "GitHub",
29
+ "HF Space",
30
+ "HF Model",
31
+ "HF Dataset",
32
+ ],
33
+ )
34
+ search_button = gr.Button("Search")
35
 
36
+ number_of_papers = gr.Textbox(label="Number of Papers Found")
37
  table = gr.HTML(show_label=False)
38
 
39
  gr.Markdown(NOTES)
paper_list.py CHANGED
@@ -8,11 +8,11 @@ from huggingface_hub.hf_api import SpaceInfo
8
 
9
  class PaperList:
10
  def __init__(self):
11
- self.organization_name = 'ICML2022'
12
- self.table = pd.read_csv('papers.csv')
13
  self._preprcess_table()
14
 
15
- self.table_header = '''
16
  <tr>
17
  <td width="50%">Paper</td>
18
  <td width="26%">Authors</td>
@@ -22,49 +22,44 @@ class PaperList:
22
  <td width="4%">HF Spaces</td>
23
  <td width="4%">HF Models</td>
24
  <td width="4%">HF Datasets</td>
25
- </tr>'''
26
 
27
  @staticmethod
28
  def load_space_info(author: str) -> list[SpaceInfo]:
29
- path = 'https://huggingface.co/api/spaces'
30
- r = requests.get(path, params={'author': author})
31
  d = r.json()
32
  return [SpaceInfo(**x) for x in d]
33
 
34
- def add_spaces_to_table(self, organization_name: str,
35
- df: pd.DataFrame) -> pd.DataFrame:
36
  spaces = self.load_space_info(organization_name)
37
- name2space = {
38
- s.id.split('/')[1].lower(): f'https://huggingface.co/spaces/{s.id}'
39
- for s in spaces
40
- }
41
- df['hf_space'] = df.loc[:, ['hf_space', 'github']].apply(
42
- lambda x: x[0] if isinstance(x[0], str) else name2space.get(
43
- x[1].split('/')[-1].lower()
44
- if isinstance(x[1], str) else '', np.nan),
45
- axis=1)
46
  return df
47
 
48
  def _preprcess_table(self) -> None:
49
- self.table = self.add_spaces_to_table(self.organization_name,
50
- self.table)
51
- self.table['title_lowercase'] = self.table.title.str.lower()
52
 
53
  rows = []
54
  for row in self.table.itertuples():
55
  paper = f'<a href="{row.url}" target="_blank">{row.title}</a>'
56
  pdf = f'<a href="{row.pdf}" target="_blank">pdf</a>'
57
- arxiv = f'<a href="{row.arxiv}" target="_blank">arXiv</a>' if isinstance(
58
- row.arxiv, str) else ''
59
- github = f'<a href="{row.github}" target="_blank">GitHub</a>' if isinstance(
60
- row.github, str) else ''
61
- hf_space = f'<a href="{row.hf_space}" target="_blank">Space</a>' if isinstance(
62
- row.hf_space, str) else ''
63
- hf_model = f'<a href="{row.hf_model}" target="_blank">Model</a>' if isinstance(
64
- row.hf_model, str) else ''
65
- hf_dataset = f'<a href="{row.hf_dataset}" target="_blank">Dataset</a>' if isinstance(
66
- row.hf_dataset, str) else ''
67
- row = f'''
68
  <tr>
69
  <td>{paper}</td>
70
  <td>{row.authors}</td>
@@ -74,31 +69,34 @@ class PaperList:
74
  <td>{hf_space}</td>
75
  <td>{hf_model}</td>
76
  <td>{hf_dataset}</td>
77
- </tr>'''
78
  rows.append(row)
79
- self.table['html_table_content'] = rows
80
 
81
- def render(self, search_query: str, case_sensitive: bool,
82
- filter_names: list[str]) -> tuple[int, str]:
83
  df = self.add_spaces_to_table(self.organization_name, self.table)
84
  if search_query:
85
  if case_sensitive:
86
  df = df[df.title.str.contains(search_query)]
87
  else:
88
  df = df[df.title_lowercase.str.contains(search_query.lower())]
89
- has_arxiv = 'arXiv' in filter_names
90
- has_github = 'GitHub' in filter_names
91
- has_hf_space = 'HF Space' in filter_names
92
- has_hf_model = 'HF Model' in filter_names
93
- has_hf_dataset = 'HF Dataset' in filter_names
94
- df = self.filter_table(df, has_arxiv, has_github, has_hf_space,
95
- has_hf_model, has_hf_dataset)
96
  return len(df), self.to_html(df, self.table_header)
97
 
98
  @staticmethod
99
- def filter_table(df: pd.DataFrame, has_arxiv: bool, has_github: bool,
100
- has_hf_space: bool, has_hf_model: bool,
101
- has_hf_dataset: bool) -> pd.DataFrame:
 
 
 
 
 
102
  if has_arxiv:
103
  df = df[~df.arxiv.isna()]
104
  if has_github:
@@ -113,10 +111,10 @@ class PaperList:
113
 
114
  @staticmethod
115
  def to_html(df: pd.DataFrame, table_header: str) -> str:
116
- table_data = ''.join(df.html_table_content)
117
- html = f'''
118
  <table>
119
  {table_header}
120
  {table_data}
121
- </table>'''
122
  return html
 
8
 
9
  class PaperList:
10
  def __init__(self):
11
+ self.organization_name = "ICML2022"
12
+ self.table = pd.read_csv("papers.csv")
13
  self._preprcess_table()
14
 
15
+ self.table_header = """
16
  <tr>
17
  <td width="50%">Paper</td>
18
  <td width="26%">Authors</td>
 
22
  <td width="4%">HF Spaces</td>
23
  <td width="4%">HF Models</td>
24
  <td width="4%">HF Datasets</td>
25
+ </tr>"""
26
 
27
  @staticmethod
28
  def load_space_info(author: str) -> list[SpaceInfo]:
29
+ path = "https://huggingface.co/api/spaces"
30
+ r = requests.get(path, params={"author": author})
31
  d = r.json()
32
  return [SpaceInfo(**x) for x in d]
33
 
34
+ def add_spaces_to_table(self, organization_name: str, df: pd.DataFrame) -> pd.DataFrame:
 
35
  spaces = self.load_space_info(organization_name)
36
+ name2space = {s.id.split("/")[1].lower(): f"https://huggingface.co/spaces/{s.id}" for s in spaces}
37
+ df["hf_space"] = df.loc[:, ["hf_space", "github"]].apply(
38
+ lambda x: (
39
+ x[0]
40
+ if isinstance(x[0], str)
41
+ else name2space.get(x[1].split("/")[-1].lower() if isinstance(x[1], str) else "", np.nan)
42
+ ),
43
+ axis=1,
44
+ )
45
  return df
46
 
47
  def _preprcess_table(self) -> None:
48
+ self.table = self.add_spaces_to_table(self.organization_name, self.table)
49
+ self.table["title_lowercase"] = self.table.title.str.lower()
 
50
 
51
  rows = []
52
  for row in self.table.itertuples():
53
  paper = f'<a href="{row.url}" target="_blank">{row.title}</a>'
54
  pdf = f'<a href="{row.pdf}" target="_blank">pdf</a>'
55
+ arxiv = f'<a href="{row.arxiv}" target="_blank">arXiv</a>' if isinstance(row.arxiv, str) else ""
56
+ github = f'<a href="{row.github}" target="_blank">GitHub</a>' if isinstance(row.github, str) else ""
57
+ hf_space = f'<a href="{row.hf_space}" target="_blank">Space</a>' if isinstance(row.hf_space, str) else ""
58
+ hf_model = f'<a href="{row.hf_model}" target="_blank">Model</a>' if isinstance(row.hf_model, str) else ""
59
+ hf_dataset = (
60
+ f'<a href="{row.hf_dataset}" target="_blank">Dataset</a>' if isinstance(row.hf_dataset, str) else ""
61
+ )
62
+ row = f"""
 
 
 
63
  <tr>
64
  <td>{paper}</td>
65
  <td>{row.authors}</td>
 
69
  <td>{hf_space}</td>
70
  <td>{hf_model}</td>
71
  <td>{hf_dataset}</td>
72
+ </tr>"""
73
  rows.append(row)
74
+ self.table["html_table_content"] = rows
75
 
76
+ def render(self, search_query: str, case_sensitive: bool, filter_names: list[str]) -> tuple[int, str]:
 
77
  df = self.add_spaces_to_table(self.organization_name, self.table)
78
  if search_query:
79
  if case_sensitive:
80
  df = df[df.title.str.contains(search_query)]
81
  else:
82
  df = df[df.title_lowercase.str.contains(search_query.lower())]
83
+ has_arxiv = "arXiv" in filter_names
84
+ has_github = "GitHub" in filter_names
85
+ has_hf_space = "HF Space" in filter_names
86
+ has_hf_model = "HF Model" in filter_names
87
+ has_hf_dataset = "HF Dataset" in filter_names
88
+ df = self.filter_table(df, has_arxiv, has_github, has_hf_space, has_hf_model, has_hf_dataset)
 
89
  return len(df), self.to_html(df, self.table_header)
90
 
91
  @staticmethod
92
+ def filter_table(
93
+ df: pd.DataFrame,
94
+ has_arxiv: bool,
95
+ has_github: bool,
96
+ has_hf_space: bool,
97
+ has_hf_model: bool,
98
+ has_hf_dataset: bool,
99
+ ) -> pd.DataFrame:
100
  if has_arxiv:
101
  df = df[~df.arxiv.isna()]
102
  if has_github:
 
111
 
112
  @staticmethod
113
  def to_html(df: pd.DataFrame, table_header: str) -> str:
114
+ table_data = "".join(df.html_table_content)
115
+ html = f"""
116
  <table>
117
  {table_header}
118
  {table_data}
119
+ </table>"""
120
  return html
style.css CHANGED
@@ -1,5 +1,6 @@
1
  h1 {
2
  text-align: center;
 
3
  }
4
  table a {
5
  background-color: transparent;
@@ -16,7 +17,3 @@ a:hover {
16
  table, th, td {
17
  border: 1px solid;
18
  }
19
- img#visitor-badge {
20
- display: block;
21
- margin: auto;
22
- }
 
1
  h1 {
2
  text-align: center;
3
+ display: block;
4
  }
5
  table a {
6
  background-color: transparent;
 
17
  table, th, td {
18
  border: 1px solid;
19
  }