davanstrien HF staff commited on
Commit
ba466b2
1 Parent(s): 9a94aea

Renders name/hub ID as a clickable link that goes to someones Hub profile

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -214,6 +214,10 @@ def kpi_chart() -> alt.Chart:
214
 
215
  return chart
216
 
 
 
 
 
217
 
218
  def obtain_top_5_users(user_ids_annotations: Dict[str, int]) -> pd.DataFrame:
219
  """
@@ -229,6 +233,7 @@ def obtain_top_5_users(user_ids_annotations: Dict[str, int]) -> pd.DataFrame:
229
  dataframe = pd.DataFrame(
230
  user_ids_annotations.items(), columns=["Name", "Submitted Responses"]
231
  )
 
232
  dataframe = dataframe.sort_values(by="Submitted Responses", ascending=False)
233
  return dataframe.head(50)
234
 
@@ -328,7 +333,7 @@ def main() -> None:
328
  value=top5_dataframe,
329
  headers=["Name", "Submitted Responses"],
330
  datatype=[
331
- "str",
332
  "number",
333
  ],
334
  row_count=50,
 
214
 
215
  return chart
216
 
217
+ def render_hub_user_link(hub_id):
218
+ link = f"https://huggingface.co/{hub_id}"
219
+ return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{hub_id}</a>'
220
+
221
 
222
  def obtain_top_5_users(user_ids_annotations: Dict[str, int]) -> pd.DataFrame:
223
  """
 
233
  dataframe = pd.DataFrame(
234
  user_ids_annotations.items(), columns=["Name", "Submitted Responses"]
235
  )
236
+ dataframe['Name'] = dataframe['Name'].apply(render_hub_user_link)
237
  dataframe = dataframe.sort_values(by="Submitted Responses", ascending=False)
238
  return dataframe.head(50)
239
 
 
333
  value=top5_dataframe,
334
  headers=["Name", "Submitted Responses"],
335
  datatype=[
336
+ "markdown",
337
  "number",
338
  ],
339
  row_count=50,