Spaces:
Paused
Paused
First try: display whether dataset is private or public and licensed
Browse files
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 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
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 |
|