Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
06fe586
1
Parent(s):
676e2ea
added debug mode locally, fixed a couple typos
Browse files
app.py
CHANGED
@@ -33,6 +33,8 @@ ref_level_len = {"validation": {1: 53, 2: 86, 3: 26}, "test": {1: 93, 2: 159, 3:
|
|
33 |
|
34 |
os.makedirs("scored", exist_ok=True)
|
35 |
|
|
|
|
|
36 |
# Display the results
|
37 |
eval_results = load_dataset(RESULTS_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
38 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
@@ -81,8 +83,8 @@ def add_new_eval(
|
|
81 |
profile: gr.OAuthProfile,
|
82 |
):
|
83 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
84 |
-
user_submission_dates = sorted(row["date"] for row in
|
85 |
-
if user_submission_dates[-1] == datetime.datetime.today().strftime('%Y-%m-%d'):
|
86 |
return format_error("You already submitted once today, please try again tomorrow.")
|
87 |
|
88 |
|
@@ -102,13 +104,16 @@ def add_new_eval(
|
|
102 |
return format_warning("Please attach a file.")
|
103 |
|
104 |
# Save submitted file
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
112 |
|
113 |
# Compute score
|
114 |
file_path = path_to_file.name
|
@@ -157,24 +162,27 @@ def add_new_eval(
|
|
157 |
return format_error(f"Your submission has {num_questions[1]} questions for level 1, {num_questions[2]} for level 2, and {num_questions[3]} for level 3, but it should have {ref_level_len[val_or_test][1]}, {ref_level_len[val_or_test][2]}, and {ref_level_len[val_or_test][3]} respectively. Please check your submission.")
|
158 |
|
159 |
# Save scored file
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
path_in_repo=f"{organisation}/{model}/{YEAR_VERSION}_{val_or_test}_scored_{datetime.datetime.today()}.jsonl",
|
164 |
-
repo_type="dataset",
|
165 |
-
token=TOKEN
|
166 |
-
)
|
167 |
-
|
168 |
-
# Save scored file
|
169 |
-
if is_validation:
|
170 |
api.upload_file(
|
171 |
-
repo_id=
|
172 |
path_or_fileobj=f"scored/{organisation}_{model}.jsonl",
|
173 |
path_in_repo=f"{organisation}/{model}/{YEAR_VERSION}_{val_or_test}_scored_{datetime.datetime.today()}.jsonl",
|
174 |
repo_type="dataset",
|
175 |
token=TOKEN
|
176 |
)
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
# Actual submission
|
179 |
eval_entry = {
|
180 |
"model": model,
|
@@ -193,7 +201,10 @@ def add_new_eval(
|
|
193 |
|
194 |
eval_results[val_or_test] = eval_results[val_or_test].add_item(eval_entry)
|
195 |
print(eval_results)
|
196 |
-
|
|
|
|
|
|
|
197 |
|
198 |
contact_info = {
|
199 |
"model": model,
|
@@ -205,7 +216,10 @@ def add_new_eval(
|
|
205 |
"date": datetime.datetime.today().strftime('%Y-%m-%d')
|
206 |
}
|
207 |
contact_infos[val_or_test]= contact_infos[val_or_test].add_item(contact_info)
|
208 |
-
|
|
|
|
|
|
|
209 |
|
210 |
return format_log(f"Model {model} submitted by {organisation} successfully.\nPlease wait a few hours and refresh the leaderboard to see your score displayed.")
|
211 |
|
|
|
33 |
|
34 |
os.makedirs("scored", exist_ok=True)
|
35 |
|
36 |
+
LOCAL_DEBUG = False
|
37 |
+
|
38 |
# Display the results
|
39 |
eval_results = load_dataset(RESULTS_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
40 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
|
|
83 |
profile: gr.OAuthProfile,
|
84 |
):
|
85 |
contact_infos = load_dataset(CONTACT_DATASET, YEAR_VERSION, token=TOKEN, download_mode="force_redownload", verification_mode=VerificationMode.NO_CHECKS, trust_remote_code=True)
|
86 |
+
user_submission_dates = sorted(row["date"] for row in contact_infos[val_or_test] if row["username"] == profile.username)
|
87 |
+
if len(user_submission_dates) > 0 and user_submission_dates[-1] == datetime.datetime.today().strftime('%Y-%m-%d'):
|
88 |
return format_error("You already submitted once today, please try again tomorrow.")
|
89 |
|
90 |
|
|
|
104 |
return format_warning("Please attach a file.")
|
105 |
|
106 |
# Save submitted file
|
107 |
+
if LOCAL_DEBUG:
|
108 |
+
print("mock uploaded submission")
|
109 |
+
else:
|
110 |
+
api.upload_file(
|
111 |
+
repo_id=SUBMISSION_DATASET,
|
112 |
+
path_or_fileobj=path_to_file.name,
|
113 |
+
path_in_repo=f"{organisation}/{model}/{YEAR_VERSION}_{val_or_test}_raw_{datetime.datetime.today()}.jsonl",
|
114 |
+
repo_type="dataset",
|
115 |
+
token=TOKEN
|
116 |
+
)
|
117 |
|
118 |
# Compute score
|
119 |
file_path = path_to_file.name
|
|
|
162 |
return format_error(f"Your submission has {num_questions[1]} questions for level 1, {num_questions[2]} for level 2, and {num_questions[3]} for level 3, but it should have {ref_level_len[val_or_test][1]}, {ref_level_len[val_or_test][2]}, and {ref_level_len[val_or_test][3]} respectively. Please check your submission.")
|
163 |
|
164 |
# Save scored file
|
165 |
+
if LOCAL_DEBUG:
|
166 |
+
print("mock uploaded scored submission")
|
167 |
+
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
api.upload_file(
|
169 |
+
repo_id=SUBMISSION_DATASET,
|
170 |
path_or_fileobj=f"scored/{organisation}_{model}.jsonl",
|
171 |
path_in_repo=f"{organisation}/{model}/{YEAR_VERSION}_{val_or_test}_scored_{datetime.datetime.today()}.jsonl",
|
172 |
repo_type="dataset",
|
173 |
token=TOKEN
|
174 |
)
|
175 |
|
176 |
+
# Save scored file
|
177 |
+
if is_validation:
|
178 |
+
api.upload_file(
|
179 |
+
repo_id=SUBMISSION_DATASET_PUBLIC,
|
180 |
+
path_or_fileobj=f"scored/{organisation}_{model}.jsonl",
|
181 |
+
path_in_repo=f"{organisation}/{model}/{YEAR_VERSION}_{val_or_test}_scored_{datetime.datetime.today()}.jsonl",
|
182 |
+
repo_type="dataset",
|
183 |
+
token=TOKEN
|
184 |
+
)
|
185 |
+
|
186 |
# Actual submission
|
187 |
eval_entry = {
|
188 |
"model": model,
|
|
|
201 |
|
202 |
eval_results[val_or_test] = eval_results[val_or_test].add_item(eval_entry)
|
203 |
print(eval_results)
|
204 |
+
if LOCAL_DEBUG:
|
205 |
+
print("mock uploaded results to lb")
|
206 |
+
else:
|
207 |
+
eval_results.push_to_hub(RESULTS_DATASET, config_name = YEAR_VERSION, token=TOKEN)
|
208 |
|
209 |
contact_info = {
|
210 |
"model": model,
|
|
|
216 |
"date": datetime.datetime.today().strftime('%Y-%m-%d')
|
217 |
}
|
218 |
contact_infos[val_or_test]= contact_infos[val_or_test].add_item(contact_info)
|
219 |
+
if LOCAL_DEBUG:
|
220 |
+
print("mock uploaded contact info")
|
221 |
+
else:
|
222 |
+
contact_infos.push_to_hub(CONTACT_DATASET, config_name = YEAR_VERSION, token=TOKEN)
|
223 |
|
224 |
return format_log(f"Model {model} submitted by {organisation} successfully.\nPlease wait a few hours and refresh the leaderboard to see your score displayed.")
|
225 |
|