Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 2,691 Bytes
c6ee831 fcb283e c6ee831 a431d31 c6ee831 a431d31 c6ee831 fcb283e c6ee831 a431d31 c6ee831 7666b36 c6ee831 2cce3db c6ee831 a431d31 c6ee831 a431d31 c6ee831 c4eee53 c6ee831 5ee220a c6ee831 b0c1665 c6ee831 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
from huggingface_hub import hf_hub_download
import json
import gzip
usernames = {}
filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset", revision="v1.1")
with gzip.open(filepath, 'r') as f:
usernames["v1.1"] = json.loads(f.read().decode('utf-8'))
filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset")
with gzip.open(filepath, 'r') as f:
usernames["v1.0"] = json.loads(f.read().decode('utf-8'))
text = """\
![](https://huggingface.co/spaces/bigcode/in-the-stack/resolve/main/banner.png)
**_The Stack is an open governance interface between the AI community and the open source community._**
# Am I in The Stack?
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.
""" + """\
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).
"""
def check_username(username, version):
output_md = ""
if username in usernames[version] and len(usernames[version][username])>0:
repos = usernames[version][username]
repo_word = "repository" if len(repos)==1 else "repositories"
output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
for repo in repos:
output_md += f"_{repo}_\n\n"
else:
output_md += "**No**, your code is not in The Stack."
return output_md.strip()
with gr.Blocks() as demo:
with gr.Row():
_, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
with colum_2:
gr.Markdown(text)
version = gr.Dropdown(["v1.1", "v1.0"], label="The Stack version:", value="v1.1")
username = gr.Text("", label="Your GitHub username:")
check_button = gr.Button("Check!")
repos = gr.Markdown()
check_button.click(check_username, [username, version], repos)
demo.launch() |