cakiki commited on
Commit
7209bc9
1 Parent(s): 2eb2fa2

First try: display whether dataset is private or public and licensed

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -1,25 +1,36 @@
1
- import http.client as http_client
2
  import json
3
- import logging
4
  import os
5
- import re
6
- import string
7
-
8
  import gradio as gr
9
  import requests
 
 
 
 
10
 
 
11
 
12
  def get_docid_html(docid):
13
  data_org, dataset, docid = docid.split("/")
14
-
15
- docid_html = """<a
16
- class="underline-on-hover"
17
- title="I am hovering over the text"
18
- style="color:#2D31FA;"
19
- href="https://huggingface.co/datasets/bigscience-data/{}"
20
- target="_blank">{}</a><span style="color: #7978FF;">/{}</span>""".format(
21
- dataset, data_org + "/" + dataset, docid
22
- )
 
 
 
 
 
 
 
 
 
 
 
23
  return docid_html
24
 
25
 
 
 
1
  import json
 
2
  import os
 
 
 
3
  import gradio as gr
4
  import requests
5
+ from huggingface_hub import HfApi
6
+
7
+ hf_api = HfApi()
8
+ roots_datasets = {dset.id.split("/")[-1]:dset for dset in hf_api.list_datasets(author="bigscience-data")}
9
 
10
+ # def get_dataset_metadata():
11
 
12
  def get_docid_html(docid):
13
  data_org, dataset, docid = docid.split("/")
14
+ target = data_org + "/" + dataset
15
+ metadata = roots_datasets[dataset]
16
+ if metadata.private:
17
+ docid_html = (
18
+ f"<a"
19
+ f'class="underline-on-hover"'
20
+ f'title="PRIVATE DATASET"'
21
+ f'style="color:#2D31FA;"'
22
+ f'href="https://huggingface.co/datasets/bigscience-data/{dataset}"'
23
+ f'target="_blank">{target}</a><span style="color: #7978FF;">/{docid}</span>"'
24
+ )
25
+ else:
26
+ docid_html = (
27
+ f"<a"
28
+ f'class="underline-on-hover"'
29
+ f'title="License: {metadata.tags[0].split(":")[-1]}"'
30
+ f'style="color:#2D31FA;"'
31
+ f'href="https://huggingface.co/datasets/bigscience-data/{dataset}"'
32
+ f'target="_blank">{target}</a><span style="color: #7978FF;">/{docid}</span>"'
33
+ )
34
  return docid_html
35
 
36