karimouda commited on
Commit
14eb45b
·
1 Parent(s): c00aea0
Files changed (1) hide show
  1. src/submission/submit.py +24 -12
src/submission/submit.py CHANGED
@@ -108,18 +108,30 @@ def add_new_eval(
108
 
109
  ##update queue file
110
  queue_file = "./eval_queue.json"
111
- #append the new entry to the queue file
112
- queue_entries = []
113
- if os.path.exists(queue_file):
114
- print("Queue file exists")
115
- with open(queue_file, "r") as f:
116
- queue_entries = json.load(f)
117
- queue_entries.append(eval_entry)
118
- else:
119
- print("Queue file exists")
120
- queue_entries.append(eval_entry)
121
- with open(queue_file, "w") as f:
122
- json.dump(queue_entries, f, indent=4)
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
 
125
  print("Uploading eval file")
 
108
 
109
  ##update queue file
110
  queue_file = "./eval_queue.json"
111
+
112
+ ## download queue_file from repo using huggun face hub API, update it and upload again
113
+ queue_file = API.download_file(
114
+ path_in_repo=queue_file,
115
+ repo_id=QUEUE_REPO,
116
+ repo_type="space",
117
+ revision="main",
118
+ token=TOKEN,
119
+ )
120
+ with open(queue_file, "r") as f:
121
+ queue_data = json.load(f)
122
+ if len(queue_data) == 0:
123
+ queue_data = []
124
+ queue_data.append(eval_entry)
125
+ with open(queue_file, "w") as f:
126
+ json.dump(queue_data, f)
127
+ print("Updating queue file")
128
+ API.upload_file(
129
+ path_or_fileobj=queue_file,
130
+ path_in_repo=queue_file,
131
+ repo_id=QUEUE_REPO,
132
+ repo_type="space",
133
+ commit_message=f"Update eval queue with {model}",
134
+ )
135
 
136
 
137
  print("Uploading eval file")