Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,55 @@
|
|
1 |
-
|
2 |
-
import streamlit as st
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
-
import gzip
|
5 |
import json
|
6 |
-
import
|
|
|
7 |
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
st.title("Am I in The Stack?")
|
21 |
-
st.markdown("As part of the BigCode project, we released and maintain [The Stack](https://huggingface.co/datasets/bigcode/the-stack), a 3.1 TB dataset of permissively licensed source code in 30 programming languages. One of our goals in this project is to give people agency over their source code by letting them decide whether or not it should be used to develop and evaluate machine learning models, as we acknowledge that not all developers may wish to have their data used for that purpose.")
|
22 |
|
23 |
-
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
31 |
repo_word = "repository" if len(repos)==1 else "repositories"
|
32 |
-
|
33 |
for repo in repos:
|
34 |
-
|
35 |
else:
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
|
|
2 |
from huggingface_hub import hf_hub_download
|
|
|
3 |
import json
|
4 |
+
import gzip
|
5 |
+
|
6 |
|
7 |
+
usernames = {}
|
8 |
|
9 |
+
filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset", revision="v1.1")
|
10 |
+
with gzip.open(filepath, 'r') as f:
|
11 |
+
usernames["v1.1"] = json.loads(f.read().decode('utf-8'))
|
12 |
|
13 |
+
filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset")
|
14 |
+
with gzip.open(filepath, 'r') as f:
|
15 |
+
usernames["v1.0"] = json.loads(f.read().decode('utf-8'))
|
16 |
|
17 |
+
text = """\
|
18 |
+
![](https://huggingface.co/spaces/bigcode/in-the-stack/resolve/main/banner.png)
|
19 |
+
**_The Stack is an open governance interface between the AI community and the open source community._**
|
20 |
|
21 |
+
# Am I in The Stack?
|
|
|
|
|
22 |
|
23 |
+
As part of the BigCode project, we released and maintain [The Stack](https://huggingface.co/datasets/bigcode/the-stack), a 3.1 TB dataset of permissively licensed source code in 30 programming languages. One of our goals in this project is to give people agency over their source code by letting them decide whether or not it should be used to develop and evaluate machine learning models, as we acknowledge that not all developers may wish to have their data used for that purpose.
|
24 |
+
""" + """\
|
25 |
|
26 |
+
This tool lets you check if a repository under a given username is part of The Stack dataset. Would you like to have your data removed from future versions of The Stack? You can opt-out following the instructions [here](https://www.bigcode-project.org/docs/about/the-stack/#how-can-i-request-that-my-data-be-removed-from-the-stack).
|
27 |
+
"""
|
28 |
|
29 |
+
def check_username(username, version):
|
30 |
+
output_md = ""
|
31 |
+
if username in usernames[version] and len(usernames[version][username])>0:
|
32 |
+
repos = usernames[version][username]
|
33 |
repo_word = "repository" if len(repos)==1 else "repositories"
|
34 |
+
output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
|
35 |
for repo in repos:
|
36 |
+
output_md += f"_{repo}_\n\n"
|
37 |
else:
|
38 |
+
output_md += "**No**, your code is not in The Stack."
|
39 |
+
return output_md.strip()
|
40 |
+
|
41 |
+
with gr.Blocks() as demo:
|
42 |
+
with gr.Row():
|
43 |
+
_, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
|
44 |
+
with colum_2:
|
45 |
+
gr.Markdown(text)
|
46 |
+
version = gr.Dropdown(["v1.1", "v1.0"], label="The Stack version:", value="v1.1")
|
47 |
+
username = gr.Text("", label="Your GitHub username:")
|
48 |
+
check_button = gr.Button("Check!")
|
49 |
+
|
50 |
+
repos = gr.Markdown()
|
51 |
+
|
52 |
+
check_button.click(check_username, [username, version], repos)
|
53 |
+
|
54 |
+
|
55 |
+
demo.launch()
|