alozowski HF staff commited on
Commit
36a18e0
1 Parent(s): 49a5f27

vote-system-bugfix (#878)

Browse files

- Fix vote system bug [WIP] (f02f25c3942ac94182042b8c7f9fb5c3c000f0ad)
- Fix vote system bug (19d46ae89985699c4361e6bf10b016fa071ac77b)

Files changed (1) hide show
  1. src/voting/vote_system.py +6 -2
src/voting/vote_system.py CHANGED
@@ -56,8 +56,9 @@ class VoteManager:
56
  return "main"
57
 
58
  def create_request_vote_df(self, pending_models_df: gr.Dataframe):
59
- if pending_models_df.empty or not "model_name" in pending_models_df.columns:
60
  return pending_models_df
 
61
  self.vote_dataset = self.read_vote_dataset()
62
  vote_counts = self.vote_dataset.groupby(['model', 'revision']).size().reset_index(name='vote_count')
63
 
@@ -79,7 +80,7 @@ class VoteManager:
79
  def add_vote(
80
  self,
81
  selected_model: str,
82
- pending_models_df: gr.Dataframe,
83
  profile: gr.OAuthProfile | None
84
  ):
85
  logger.debug(f"Type of list before usage: {type(list)}")
@@ -126,6 +127,9 @@ class VoteManager:
126
  self.vote_check_set.add(check_tuple)
127
  gr.Info(f"Voted for {selected_model}")
128
 
 
 
 
129
  return self.create_request_vote_df(pending_models_df)
130
 
131
  def upload_votes(self):
 
56
  return "main"
57
 
58
  def create_request_vote_df(self, pending_models_df: gr.Dataframe):
59
+ if pending_models_df.empty or "model_name" not in pending_models_df.columns:
60
  return pending_models_df
61
+
62
  self.vote_dataset = self.read_vote_dataset()
63
  vote_counts = self.vote_dataset.groupby(['model', 'revision']).size().reset_index(name='vote_count')
64
 
 
80
  def add_vote(
81
  self,
82
  selected_model: str,
83
+ pending_models_df: gr.Dataframe | None,
84
  profile: gr.OAuthProfile | None
85
  ):
86
  logger.debug(f"Type of list before usage: {type(list)}")
 
127
  self.vote_check_set.add(check_tuple)
128
  gr.Info(f"Voted for {selected_model}")
129
 
130
+ if pending_models_df is None:
131
+ return
132
+
133
  return self.create_request_vote_df(pending_models_df)
134
 
135
  def upload_votes(self):