anton-l HF Staff commited on
Commit
8addc5b
Β·
verified Β·
1 Parent(s): 1168a3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -28
app.py CHANGED
@@ -2,7 +2,10 @@ import gradio as gr
2
  import duckdb
3
  import urllib.parse
4
 
5
- PARQUET_PATH = "/data/v3_repos.parquet"
 
 
 
6
 
7
  con = duckdb.connect()
8
 
@@ -19,39 +22,37 @@ We want to give developers agency over their source code \
19
  by letting them decide whether or not it should be used to develop and evaluate \
20
  machine learning models.
21
 
22
- Enter your GitHub username below to check if any of your repositories are in The Stack v3. \
23
- If your code is found, you will get a pre-filled opt-out link \
24
- that submits a properly formatted removal request on your behalf. \
25
- **Please use this tool to submit opt-out requests** rather than opening issues manually β€” \
26
- it ensures your request can be processed quickly and correctly.
27
  """
28
 
29
  opt_out_text_template = """\
30
  ### Opt-out
31
 
32
- If you want your data to be removed from The Stack and model training, \
33
- 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> \
34
- (if the link doesn't work, try right-clicking and opening it in a new tab) \
35
- 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).\
 
36
  """
37
 
38
- opt_out_issue_title = "Opt-out request for {username}"
39
- opt_out_issue_body = """\
40
- I request that the following data is removed from The Stack:
41
 
42
- {repo_list}
 
43
 
44
- _Note_: If you don't want all repositories removed, edit the list above. \
45
- To exclude everything under your username, replace the list with a single "all" entry.
46
- """
47
-
48
-
49
- def issue_url(username, repos):
50
- title = urllib.parse.quote(opt_out_issue_title.format(username=username))
51
- body = urllib.parse.quote(
52
- opt_out_issue_body.format(repo_list=" - " + "\n - ".join(repos))
53
- )
54
- return opt_out_text_template.format(title=title, body=body)
55
 
56
 
57
  def check_username(username):
@@ -76,8 +77,7 @@ def check_username(username):
76
  lines.append(f"[{full}](https://github.com/{full})\n")
77
  output_md = "\n".join(lines).strip()
78
 
79
- full_names = [f"{username}/{r}" for r in repos]
80
- return output_md, issue_url(username, full_names)
81
 
82
 
83
  with gr.Blocks() as demo:
@@ -86,7 +86,7 @@ with gr.Blocks() as demo:
86
  with col:
87
  gr.HTML(huggy_html)
88
  gr.Markdown(text)
89
- username = gr.Text("", label="Your GitHub username:")
90
  check_button = gr.Button("Check!")
91
  repos_md = gr.Markdown()
92
  opt_out_md = gr.Markdown()
 
2
  import duckdb
3
  import urllib.parse
4
 
5
+ PARQUET_PATH = "data/v3_repos.parquet"
6
+ OPT_OUT_REPO = "bigcode-project/opt-out-v2"
7
+ NEW_ISSUE_URL = f"https://github.com/{OPT_OUT_REPO}/issues/new"
8
+ TEMPLATE = "opt-out-request.yml"
9
 
10
  con = duckdb.connect()
11
 
 
22
  by letting them decide whether or not it should be used to develop and evaluate \
23
  machine learning models.
24
 
25
+ Enter your GitHub username (or an organization name) below to check if any of its \
26
+ repositories are in The Stack v3. If your code is found, you'll get a pre-filled \
27
+ opt-out link that submits a properly formatted removal request on your behalf. \
28
+ **Please use this tool to submit opt-out requests** rather than opening issues \
29
+ manually β€” it ensures your request can be processed quickly and correctly.
30
  """
31
 
32
  opt_out_text_template = """\
33
  ### Opt-out
34
 
35
+ If you want your data removed from The Stack and model training, \
36
+ <a href="{url}" target="_blank">open a pre-filled opt-out request</a> \
37
+ (if the link doesn't work, try right-clicking and opening it in a new tab). \
38
+ The form lets you remove your whole account or just specific repositories, and \
39
+ add any other accounts or organizations you own β€” it walks you through it.\
40
  """
41
 
 
 
 
42
 
43
+ def issue_url(username: str) -> str:
44
+ """Link to the opt-out issue form, pre-seeded with the looked-up account.
45
 
46
+ Seeds the "remove entirely" list with the username; the form itself guides
47
+ the user through narrowing to specific repos or adding more accounts/orgs.
48
+ """
49
+ params = {
50
+ "template": TEMPLATE,
51
+ "title": "Opt-out request",
52
+ "remove_accounts": username,
53
+ }
54
+ query = urllib.parse.urlencode(params, quote_via=urllib.parse.quote)
55
+ return opt_out_text_template.format(url=f"{NEW_ISSUE_URL}?{query}")
 
56
 
57
 
58
  def check_username(username):
 
77
  lines.append(f"[{full}](https://github.com/{full})\n")
78
  output_md = "\n".join(lines).strip()
79
 
80
+ return output_md, issue_url(username)
 
81
 
82
 
83
  with gr.Blocks() as demo:
 
86
  with col:
87
  gr.HTML(huggy_html)
88
  gr.Markdown(text)
89
+ username = gr.Text("", label="Your GitHub username or organization:")
90
  check_button = gr.Button("Check!")
91
  repos_md = gr.Markdown()
92
  opt_out_md = gr.Markdown()