CoolFace
Apppublic

HuggingFaceCode/in-the-stack

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
16likes
app.py96 linesDownload Raw Back to root
1import gradio as gr2import duckdb3import urllib.parse4 5PARQUET_PATH = "/data/v3_repos.parquet"6OPT_OUT_REPO = "bigcode-project/opt-out-v2"7NEW_ISSUE_URL = f"https://github.com/{OPT_OUT_REPO}/issues/new"8TEMPLATE = "opt-out-request.yml"9 10con = duckdb.connect()11 12huggy_html = '<img src="https://huggingface.co/spaces/HuggingFaceCode/in-the-stack/resolve/main/huggy.png" style="width: 20%;">'13 14text = """\15# Am I in The Stack?16 17[The Stack v3](https://huggingface.co/datasets/HuggingFaceCode/stack-v3-train) is \18a 15.9 TB dataset of source code across 713 programming languages from 173M repositories, \19crawled from GitHub in 2025.20 21We want to give developers agency over their source code \22by letting them decide whether or not it should be used to develop and evaluate \23machine learning models.24 25Enter your GitHub username (or an organization name) below to check if any of its \26repositories are in The Stack v3. If your code is found, you'll get a pre-filled \27opt-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 \29manually — it ensures your request can be processed quickly and correctly.30"""31 32opt_out_text_template = """\33### Opt-out34 35If 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). \38The form lets you remove your whole account or just specific repositories, and \39add any other accounts or organizations you own — it walks you through it.\40"""41 42 43def 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 guides47    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 58def check_username(username):59    username = username.strip()60    if not username:61        return "", ""62 63    repos = con.execute(64        f"""SELECT repo FROM read_parquet('{PARQUET_PATH}')65            WHERE "user" = $1 ORDER BY repo""",66        [username.lower()],67    ).fetchall()68    repos = [row[0] for row in repos]69 70    if not repos:71        return "**No**, your code is not in The Stack v3.", ""72 73    repo_word = "repository" if len(repos) == 1 else "repositories"74    lines = [f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack v3:\n"]75    for repo in repos:76        full = f"{username}/{repo}"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 83with gr.Blocks() as demo:84    with gr.Row():85        _, col, _ = gr.Column(scale=1), gr.Column(scale=6), gr.Column(scale=1)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()93            check_button.click(check_username, [username], [repos_md, opt_out_md])94 95demo.launch()96