Spaces:
Running
on
Zero
Running
on
Zero
removed backup vote_details (#19)
Browse files- removed backup vote_details (0c473f3259fdcdde4d8c494b38877f9a4f0fe813)
Co-authored-by: Kai <kai-aizip@users.noreply.huggingface.co>
- utils/vote_logger.py +2 -16
utils/vote_logger.py
CHANGED
|
@@ -47,21 +47,7 @@ def save_vote_details(example, model_a, model_b, winner, feedback, summary_a, su
|
|
| 47 |
|
| 48 |
print(f"Vote details saved to {csv_path}")
|
| 49 |
except Exception as e:
|
| 50 |
-
print(f"Error saving vote details: {e}")
|
| 51 |
-
|
| 52 |
-
# Create a backup copy every 10 votes
|
| 53 |
-
try:
|
| 54 |
-
if os.path.exists(csv_path):
|
| 55 |
-
with open(csv_path, 'r', encoding='utf-8') as f:
|
| 56 |
-
num_votes = sum(1 for _ in f) - 1 # Subtract 1 for header
|
| 57 |
-
|
| 58 |
-
if num_votes % 10 == 0:
|
| 59 |
-
backup_path = os.path.join('utils', f'vote_details_backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}.csv')
|
| 60 |
-
with open(csv_path, 'r', encoding='utf-8') as src, open(backup_path, 'w', encoding='utf-8') as dst:
|
| 61 |
-
dst.write(src.read())
|
| 62 |
-
print(f"Created backup at {backup_path}")
|
| 63 |
-
except Exception as e:
|
| 64 |
-
print(f"Error creating backup: {e}")
|
| 65 |
|
| 66 |
def get_vote_statistics():
|
| 67 |
"""
|
|
@@ -118,4 +104,4 @@ def get_vote_statistics():
|
|
| 118 |
return stats
|
| 119 |
|
| 120 |
except Exception as e:
|
| 121 |
-
return {"error": f"Error analyzing vote data: {e}"}
|
|
|
|
| 47 |
|
| 48 |
print(f"Vote details saved to {csv_path}")
|
| 49 |
except Exception as e:
|
| 50 |
+
print(f"Error saving vote details: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
def get_vote_statistics():
|
| 53 |
"""
|
|
|
|
| 104 |
return stats
|
| 105 |
|
| 106 |
except Exception as e:
|
| 107 |
+
return {"error": f"Error analyzing vote data: {e}"}
|