rootacess commited on
Commit
7817c3d
1 Parent(s): 776d922

initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. app.py +81 -0
  3. banner.png +0 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .idea
2
+ venv
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ import json
4
+ import urllib
5
+
6
+ filepath = hf_hub_download(repo_id="bigcode/commits-username-to-repo", filename="username_to_repo.json",
7
+ repo_type="dataset", token="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")
8
+ with open(filepath, 'r') as f:
9
+ username_to_repo = json.load(f)
10
+
11
+ usernames = set(username_to_repo.keys())
12
+
13
+ text = """\
14
+ ![](https://huggingface.co/spaces/lvwerra/in-the-stack-gr/resolve/main/banner.png)
15
+ **_CommitPack is..._**
16
+
17
+ # Am I in The CommitPack?
18
+
19
+ As part of the BigCode project, we released and maintain [The Stack](https://huggingface.co/datasets/bigcode/the-stack), a 6 TB dataset of permissively licensed source code over 300 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.
20
+ """ + """\
21
+
22
+ 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).
23
+ """
24
+
25
+ opt_out_text_template = """\
26
+ ### Opt-out
27
+
28
+ If you want your data to be removed from the stack and model training \
29
+ open an issue with <a href="https://github.com/bigcode-project/opt-out-v2/issues/new?title={title}&body={body}" target="_blank">this link</a> \
30
+ (if the link doesn't work try right a right click and open it in a new tab) or visit [https://github.com/bigcode-project/opt-out-v2/issues/new?&template=opt-out-request.md](https://github.com/bigcode-project/opt-out-v2/issues/new?&template=opt-out-request.md) .\
31
+ """
32
+
33
+ opt_out_issue_title = """Opt-out request for {username}"""
34
+ opt_out_issue_body = """\
35
+ I request that the following data is removed from The Stack:
36
+
37
+ - Commits
38
+ - GitHub issue
39
+ {repo_list}
40
+
41
+ _Note_: If you don't want all resources to be included just remove the elements from the list above. If you would like to exclude all repositories and resources just add a single element "all" to the list.
42
+ """
43
+
44
+
45
+ def issue_url(username, repos):
46
+ title = urllib.parse.quote(opt_out_issue_title.format(username=username))
47
+ body = urllib.parse.quote(opt_out_issue_body.format(repo_list=" - " + "\n - ".join(repos)))
48
+
49
+ opt_out_text = opt_out_text_template.format(title=title, body=body)
50
+
51
+ return opt_out_text
52
+
53
+
54
+ def check_username(username):
55
+ output_md = ""
56
+ if username in usernames and len(username_to_repo[username]) > 0:
57
+ repos = username_to_repo[username]
58
+ repo_word = "repository" if len(repos) == 1 else "repositories"
59
+ output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
60
+ for repo in repos:
61
+ output_md += f"_{repo}_\n\n"
62
+
63
+ return output_md.strip(), issue_url(username, repos)
64
+ else:
65
+ output_md += "**No**, your code is not in The Stack."
66
+ return output_md.strip(), ""
67
+
68
+
69
+ with gr.Blocks() as demo:
70
+ with gr.Row():
71
+ _, colum_2, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)
72
+ with colum_2:
73
+ gr.Markdown(text)
74
+ username = gr.Text("", label="Your GitHub username:")
75
+ check_button = gr.Button("Check!")
76
+ repos = gr.Markdown()
77
+ opt_out = gr.Markdown()
78
+
79
+ check_button.click(check_username, [username], [repos, opt_out])
80
+
81
+ demo.launch()
banner.png ADDED