Spaces:
Running
Running
Update GUI to differentiate private / public datasets (#1)
Browse files- Update GUI to differentiate private / public datasets (c14707a572ca962572423e208b48f689c436b043)
Co-authored-by: Christopher Akiki <[email protected]>
app.py
CHANGED
@@ -7,19 +7,32 @@ 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 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return docid_html
|
24 |
|
25 |
|
|
|
7 |
|
8 |
import gradio as gr
|
9 |
import requests
|
10 |
+
from huggingface_hub import HfApi
|
11 |
|
12 |
+
hf_api = HfApi()
|
13 |
+
roots_datasets = {dset.id.split("/")[-1]:dset for dset in hf_api.list_datasets(author="bigscience-data", use_auth_token=os.environ.get("bigscience_data_token"))}
|
14 |
|
15 |
def get_docid_html(docid):
|
16 |
data_org, dataset, docid = docid.split("/")
|
17 |
+
metadata = roots_datasets[dataset]
|
18 |
+
if metadata.private:
|
19 |
+
docid_html = (
|
20 |
+
f"<a "
|
21 |
+
f'class="underline-on-hover"'
|
22 |
+
f'title="This dataset is private. See the introductory text for more information"'
|
23 |
+
f'style="color:#AA4A44;"'
|
24 |
+
f'href="https://huggingface.co/datasets/bigscience-data/{dataset}"'
|
25 |
+
f'target="_blank"><b>๐{dataset}</b></a><span style="color: #7978FF;">/{docid}</span>'
|
26 |
+
)
|
27 |
+
else:
|
28 |
+
docid_html = (
|
29 |
+
f"<a "
|
30 |
+
f'class="underline-on-hover"'
|
31 |
+
f'title="This dataset is licensed {metadata.tags[0].split(":")[-1]}"'
|
32 |
+
f'style="color:#2D31FA;"'
|
33 |
+
f'href="https://huggingface.co/datasets/bigscience-data/{dataset}"'
|
34 |
+
f'target="_blank"><b>{dataset}</b></a><span style="color: #7978FF;">/{docid}</span>'
|
35 |
+
)
|
36 |
return docid_html
|
37 |
|
38 |
|