deema commited on
Commit
79823b5
1 Parent(s): 3c58764

add file not found

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -3,6 +3,8 @@ import pandas as pd
3
  import random
4
  from collections import defaultdict
5
  import json
 
 
6
 
7
  css = """
8
  .rtl{
@@ -34,6 +36,11 @@ def process_rankings(user_rankings):
34
  model_rankings[model][f'{rank}{rank_suffix}'] += 1 # Using the correct suffix based on the rank
35
 
36
  file_path = 'users_ranking.txt'
 
 
 
 
 
37
  with open(file_path, 'a') as file:
38
  model_rankings_dict = dict(model_rankings)
39
  json.dump(model_rankings_dict, file)
 
3
  import random
4
  from collections import defaultdict
5
  import json
6
+ import os
7
+ import sys
8
 
9
  css = """
10
  .rtl{
 
36
  model_rankings[model][f'{rank}{rank_suffix}'] += 1 # Using the correct suffix based on the rank
37
 
38
  file_path = 'users_ranking.txt'
39
+ if not os.path.exists(file_path):
40
+ # If the file path does not exist, print an error message and exit the script
41
+ print(f"Error: The file path '{file_path}' does not exist.")
42
+ sys.exit(1) # Exit the script with an error code (1 is a common choice for a general error)
43
+
44
  with open(file_path, 'a') as file:
45
  model_rankings_dict = dict(model_rankings)
46
  json.dump(model_rankings_dict, file)