Daniel Kantor commited on
Commit
f54101f
·
1 Parent(s): d7d7ccf

fix voting

Browse files
Files changed (1) hide show
  1. backend/app/services/votes.py +5 -5
backend/app/services/votes.py CHANGED
@@ -11,7 +11,7 @@ import os
11
 
12
  from app.services.hf_service import HuggingFaceService
13
  from app.config import HF_TOKEN
14
- from app.config.hf_config import HF_ORGANIZATION
15
  from app.core.cache import cache_config
16
  from app.core.formatting import LogFormatter
17
 
@@ -89,7 +89,7 @@ class VoteService(HuggingFaceService):
89
 
90
  async def _fetch_remote_votes(self) -> List[Dict[str, Any]]:
91
  """Fetch votes from HF hub"""
92
- url = f"https://huggingface.co/datasets/{HF_ORGANIZATION}/votes/raw/main/votes_data.jsonl"
93
  headers = {"Authorization": f"Bearer {self.token}"} if self.token else {}
94
 
95
  try:
@@ -160,7 +160,7 @@ class VoteService(HuggingFaceService):
160
  self.hf_api.upload_file(
161
  path_or_fileobj=temp_path,
162
  path_in_repo="votes_data.jsonl",
163
- repo_id=f"{HF_ORGANIZATION}/votes",
164
  repo_type="dataset",
165
  commit_message=f"Update votes: +{len(self.votes_to_upload)} new votes",
166
  token=self.token
@@ -363,7 +363,7 @@ class VoteService(HuggingFaceService):
363
  async def add_vote(self, model_id: str, user_id: str, vote_type: str, vote_data: Dict[str, Any] = None) -> Dict[str, Any]:
364
  """Add a vote for a model"""
365
  try:
366
- self._log_repo_operation("add", f"{HF_ORGANIZATION}/votes", f"Adding {vote_type} vote for {model_id} by {user_id}")
367
  logger.info(LogFormatter.section("NEW VOTE"))
368
  stats = {
369
  "Model": model_id,
@@ -438,4 +438,4 @@ class VoteService(HuggingFaceService):
438
 
439
  except Exception as e:
440
  logger.error(LogFormatter.error("Failed to add vote", e))
441
- raise
 
11
 
12
  from app.services.hf_service import HuggingFaceService
13
  from app.config import HF_TOKEN
14
+ from app.config.hf_config import HF_ORGANIZATION, VOTES_REPO
15
  from app.core.cache import cache_config
16
  from app.core.formatting import LogFormatter
17
 
 
89
 
90
  async def _fetch_remote_votes(self) -> List[Dict[str, Any]]:
91
  """Fetch votes from HF hub"""
92
+ url = f"https://huggingface.co/datasets/{VOTES_REPO}/raw/main/votes_data.jsonl"
93
  headers = {"Authorization": f"Bearer {self.token}"} if self.token else {}
94
 
95
  try:
 
160
  self.hf_api.upload_file(
161
  path_or_fileobj=temp_path,
162
  path_in_repo="votes_data.jsonl",
163
+ repo_id=VOTES_REPO,
164
  repo_type="dataset",
165
  commit_message=f"Update votes: +{len(self.votes_to_upload)} new votes",
166
  token=self.token
 
363
  async def add_vote(self, model_id: str, user_id: str, vote_type: str, vote_data: Dict[str, Any] = None) -> Dict[str, Any]:
364
  """Add a vote for a model"""
365
  try:
366
+ self._log_repo_operation("add", VOTES_REPO, f"Adding {vote_type} vote for {model_id} by {user_id}")
367
  logger.info(LogFormatter.section("NEW VOTE"))
368
  stats = {
369
  "Model": model_id,
 
438
 
439
  except Exception as e:
440
  logger.error(LogFormatter.error("Failed to add vote", e))
441
+ raise