import gradio as gr import duckdb import urllib.parse PARQUET_PATH = "/data/v3_repos.parquet" OPT_OUT_REPO = "bigcode-project/opt-out-v2" NEW_ISSUE_URL = f"https://github.com/{OPT_OUT_REPO}/issues/new" TEMPLATE = "opt-out-request.yml" con = duckdb.connect() huggy_html = '' text = """\ # Am I in The Stack? [The Stack v3](https://huggingface.co/datasets/HuggingFaceCode/stack-v3-train) is \ a 15.9 TB dataset of source code across 713 programming languages from 173M repositories, \ crawled from GitHub in 2025. We want to give developers agency over their source code \ by letting them decide whether or not it should be used to develop and evaluate \ machine learning models. Enter your GitHub username (or an organization name) below to check if any of its \ repositories are in The Stack v3. If your code is found, you'll get a pre-filled \ opt-out link that submits a properly formatted removal request on your behalf. \ **Please use this tool to submit opt-out requests** rather than opening issues \ manually — it ensures your request can be processed quickly and correctly. """ opt_out_text_template = """\ ### Opt-out If you want your data removed from The Stack and model training, \ open a pre-filled opt-out request \ (if the link doesn't work, try right-clicking and opening it in a new tab). \ The form lets you remove your whole account or just specific repositories, and \ add any other accounts or organizations you own — it walks you through it.\ """ def issue_url(username: str) -> str: """Link to the opt-out issue form, pre-seeded with the looked-up account. Seeds the "remove entirely" list with the username; the form itself guides the user through narrowing to specific repos or adding more accounts/orgs. """ params = { "template": TEMPLATE, "title": "Opt-out request", "remove_accounts": username, } query = urllib.parse.urlencode(params, quote_via=urllib.parse.quote) return opt_out_text_template.format(url=f"{NEW_ISSUE_URL}?{query}") def check_username(username): username = username.strip() if not username: return "", "" repos = con.execute( f"""SELECT repo FROM read_parquet('{PARQUET_PATH}') WHERE "user" = $1 ORDER BY repo""", [username.lower()], ).fetchall() repos = [row[0] for row in repos] if not repos: return "**No**, your code is not in The Stack v3.", "" repo_word = "repository" if len(repos) == 1 else "repositories" lines = [f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack v3:\n"] for repo in repos: full = f"{username}/{repo}" lines.append(f"[{full}](https://github.com/{full})\n") output_md = "\n".join(lines).strip() return output_md, issue_url(username) with gr.Blocks() as demo: with gr.Row(): _, col, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1) with col: gr.HTML(huggy_html) gr.Markdown(text) username = gr.Text("", label="Your GitHub username or organization:") check_button = gr.Button("Check!") repos_md = gr.Markdown() opt_out_md = gr.Markdown() check_button.click(check_username, [username], [repos_md, opt_out_md]) demo.launch()