wseo commited on
Commit
0df7ae2
1 Parent(s): f8f6fba

10-likes-or-nothing (#9)

Browse files

- feat: consider likes as certification metric (37c03792e90348499455829da469b646113472cc)

Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +4 -1
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
app.py CHANGED
@@ -23,12 +23,13 @@ CERTIFIED_USERS_FILENAME = "certified.csv"
23
  ORGANIZATION = "pseudolab"
24
 
25
 
26
- def has_contributions(repo_type, hf_username, organization):
27
  """
28
  Check if a user has contributions in the specified repository type.
29
  :param repo_type: A repo type supported by the Hub
30
  :param hf_username: HF Hub username
31
  :param organization: HF Hub organization
 
32
  """
33
  repo_list = {
34
  "model": api.list_models,
@@ -37,6 +38,8 @@ def has_contributions(repo_type, hf_username, organization):
37
  }
38
 
39
  for repo in repo_list[repo_type](author=organization):
 
 
40
  commits = api.list_repo_commits(repo.id, repo_type=repo_type)
41
  if any(hf_username in commit.authors for commit in commits):
42
  return True
 
23
  ORGANIZATION = "pseudolab"
24
 
25
 
26
+ def has_contributions(repo_type, hf_username, organization, likes=10):
27
  """
28
  Check if a user has contributions in the specified repository type.
29
  :param repo_type: A repo type supported by the Hub
30
  :param hf_username: HF Hub username
31
  :param organization: HF Hub organization
32
+ :param likes: Minimum number of likes for a contribution to be considered
33
  """
34
  repo_list = {
35
  "model": api.list_models,
 
38
  }
39
 
40
  for repo in repo_list[repo_type](author=organization):
41
+ if len(api.list_repo_likers(repo.id, repo_type=repo_type)) < likes:
42
+ continue
43
  commits = api.list_repo_commits(repo.id, repo_type=repo_type)
44
  if any(hf_username in commit.authors for commit in commits):
45
  return True