lvwerra HF Staff commited on
Commit
d22aa8c
·
1 Parent(s): 092ac6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -3,10 +3,16 @@ from huggingface_hub import hf_hub_download
3
  import json
4
  import gzip
5
 
 
 
 
6
  filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset", revision="v1.1")
 
 
7
 
 
8
  with gzip.open(filepath, 'r') as f:
9
- usernames = json.loads(f.read().decode('utf-8'))
10
 
11
  text = """\
12
  **_The Stack is an open governance interface between the AI community and the open source community._**
@@ -19,10 +25,10 @@ As part of the BigCode project, we released and maintain [The Stack](https://hug
19
  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).
20
  """
21
 
22
- def check_username(username):
23
  output_md = ""
24
- if username in usernames and len(usernames[username])>0:
25
- repos = usernames[username]
26
  repo_word = "repository" if len(repos)==1 else "repositories"
27
  output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
28
  for repo in repos:
@@ -33,12 +39,13 @@ def check_username(username):
33
 
34
  with gr.Blocks() as demo:
35
  gr.Markdown(text)
 
36
  username = gr.Text("", label="Your GitHub username:")
37
  check_button = gr.Button("Check!")
38
 
39
  repos = gr.Markdown()
40
 
41
- check_button.click(check_username, [username], repos)
42
 
43
 
44
  demo.launch()
 
3
  import json
4
  import gzip
5
 
6
+
7
+ usernames = {}
8
+
9
  filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset", revision="v1.1")
10
+ with gzip.open(filepath, 'r') as f:
11
+ usernames["v1.1"] = json.loads(f.read().decode('utf-8'))
12
 
13
+ filepath = hf_hub_download(repo_id="bigcode/the-stack-username-to-repo", filename="username_to_repo.json.gz", repo_type="dataset")
14
  with gzip.open(filepath, 'r') as f:
15
+ usernames["v1.0"] = json.loads(f.read().decode('utf-8'))
16
 
17
  text = """\
18
  **_The Stack is an open governance interface between the AI community and the open source community._**
 
25
  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).
26
  """
27
 
28
+ def check_username(username, version):
29
  output_md = ""
30
+ if username in usernames[version] and len(usernames[version][username])>0:
31
+ repos = usernames[version][username]
32
  repo_word = "repository" if len(repos)==1 else "repositories"
33
  output_md += f"**Yes**, there is code from **{len(repos)} {repo_word}** in The Stack:\n\n"
34
  for repo in repos:
 
39
 
40
  with gr.Blocks() as demo:
41
  gr.Markdown(text)
42
+ version = gr.Dropdown(["v1.1", "v1.0"], label="The Stack version:", value="v1.1")
43
  username = gr.Text("", label="Your GitHub username:")
44
  check_button = gr.Button("Check!")
45
 
46
  repos = gr.Markdown()
47
 
48
+ check_button.click(check_username, [username, version], repos)
49
 
50
 
51
  demo.launch()