hysts HF staff commited on
Commit
850f439
1 Parent(s): 14761b8
Files changed (2) hide show
  1. app.py +18 -5
  2. demo_list.py +5 -0
app.py CHANGED
@@ -45,14 +45,23 @@ SDK_CHOICES = [
45
  'streamlit',
46
  'docker',
47
  ]
 
 
48
 
49
 
50
- def update_df(status: list[str], hardware: list[str],
51
- sdk: list[str]) -> pd.DataFrame:
52
  df_raw = demo_list.df_raw
53
  df = demo_list.df
54
- return df[(df_raw.status.isin(status)) & (df_raw.hardware.isin(hardware)) &
55
- (df_raw.sdk.isin(sdk))]
 
 
 
 
 
 
 
56
 
57
 
58
  def update_status_checkboxes(choices: list[str]) -> list[str]:
@@ -97,6 +106,10 @@ with gr.Blocks(css='style.css') as demo:
97
  choices=['(ALL)', '(NONE)'] + SDK_CHOICES,
98
  value=SDK_CHOICES,
99
  type='value')
 
 
 
 
100
  apply_button = gr.Button('Apply')
101
  df = gr.Dataframe(value=demo_list.df,
102
  datatype=demo_list.column_datatype,
@@ -121,7 +134,7 @@ with gr.Blocks(css='style.css') as demo:
121
  show_progress=False,
122
  api_name=False)
123
  apply_button.click(fn=update_df,
124
- inputs=[status, hardware, sdk],
125
  outputs=df,
126
  api_name=False)
127
  demo.queue(api_open=False).launch()
 
45
  'streamlit',
46
  'docker',
47
  ]
48
+ WHOAMI = api.whoami()['name']
49
+ OWNER_CHOICES = [WHOAMI, 'other organizations']
50
 
51
 
52
+ def update_df(status: list[str], hardware: list[str], sdk: list[str],
53
+ owner: list[str]) -> pd.DataFrame:
54
  df_raw = demo_list.df_raw
55
  df = demo_list.df
56
+ df = df[(df_raw.status.isin(status)) & (df_raw.hardware.isin(hardware)) &
57
+ (df_raw.sdk.isin(sdk))]
58
+ if set(owner) == set(OWNER_CHOICES):
59
+ pass
60
+ elif WHOAMI in owner:
61
+ df = df[df_raw.owner == WHOAMI]
62
+ else:
63
+ df = df[df_raw.owner != WHOAMI]
64
+ return df
65
 
66
 
67
  def update_status_checkboxes(choices: list[str]) -> list[str]:
 
106
  choices=['(ALL)', '(NONE)'] + SDK_CHOICES,
107
  value=SDK_CHOICES,
108
  type='value')
109
+ owner = gr.CheckboxGroup(label='Owner',
110
+ choices=OWNER_CHOICES,
111
+ value=OWNER_CHOICES,
112
+ type='value')
113
  apply_button = gr.Button('Apply')
114
  df = gr.Dataframe(value=demo_list.df,
115
  datatype=demo_list.column_datatype,
 
134
  show_progress=False,
135
  api_name=False)
136
  apply_button.click(fn=update_df,
137
+ inputs=[status, hardware, sdk, owner],
138
  outputs=df,
139
  api_name=False)
140
  demo.queue(api_open=False).launch()
demo_list.py CHANGED
@@ -15,6 +15,7 @@ class DemoList:
15
  ['status', 'markdown'],
16
  ['hardware', 'markdown'],
17
  ['title', 'markdown'],
 
18
  ['arxiv', 'markdown'],
19
  ['github', 'markdown'],
20
  ['likes', 'number'],
@@ -57,6 +58,7 @@ class DemoList:
57
  if tag not in info:
58
  info[tag] = []
59
  info['url'] = url
 
60
  info['title'] = card['title']
61
  info['sdk'] = card['sdk']
62
  info['sdk_version'] = card.get('sdk_version', '')
@@ -108,6 +110,9 @@ class DemoList:
108
  self.to_div(row.suggested_hardware, 'hardware'),
109
  'title':
110
  self.create_link(row.title, row.url),
 
 
 
111
  'arxiv':
112
  self.get_arxiv_link(row.arxiv),
113
  'github':
 
15
  ['status', 'markdown'],
16
  ['hardware', 'markdown'],
17
  ['title', 'markdown'],
18
+ ['owner', 'markdown'],
19
  ['arxiv', 'markdown'],
20
  ['github', 'markdown'],
21
  ['likes', 'number'],
 
58
  if tag not in info:
59
  info[tag] = []
60
  info['url'] = url
61
+ info['owner'] = space_id.split('/')[0]
62
  info['title'] = card['title']
63
  info['sdk'] = card['sdk']
64
  info['sdk_version'] = card.get('sdk_version', '')
 
110
  self.to_div(row.suggested_hardware, 'hardware'),
111
  'title':
112
  self.create_link(row.title, row.url),
113
+ 'owner':
114
+ self.create_link(row.owner,
115
+ f'https://huggingface.co/{row.owner}'),
116
  'arxiv':
117
  self.get_arxiv_link(row.arxiv),
118
  'github':