lvkaokao commited on
Commit
fa9f3ea
·
1 Parent(s): 30ed943

add global lock for git-push.

Browse files
Files changed (1) hide show
  1. src/submission/submit.py +20 -13
src/submission/submit.py CHANGED
@@ -5,7 +5,7 @@ from datetime import datetime, timezone
5
  from huggingface_hub import ModelCard, snapshot_download
6
 
7
  from src.display.formatting import styled_error, styled_message, styled_warning
8
- from src.envs import API, EVAL_REQUESTS_PATH, DYNAMIC_INFO_PATH, DYNAMIC_INFO_FILE_PATH, DYNAMIC_INFO_REPO, H4_TOKEN, QUEUE_REPO, RATE_LIMIT_PERIOD, RATE_LIMIT_QUOTA, REPO, GIT_REQUESTS_PATH, GIT_STATUS_PATH
9
  from src.leaderboard.filter_models import DO_NOT_SUBMIT_MODELS
10
  from src.submission.check_validity import (
11
  already_submitted_models,
@@ -220,23 +220,30 @@ def add_new_eval(
220
  sta_out_path = f"{OUT_DIR}/{model_path}_eval_request_{private}_{quant_type}_{precision}_{weight_dtype}_{compute_dtype}.json"
221
  sta_git_path = "/".join(sta_out_path.split('/')[1:])
222
 
223
-
224
- print("Uploading eval file")
225
-
226
- REPO.index.remove("requests", False, r=True)
227
-
228
  with open(req_out_path, "w") as f:
229
  f.write(json.dumps(eval_entry, indent=4))
230
  with open(sta_out_path, "w") as f:
231
  f.write(json.dumps(eval_entry, indent=4))
232
 
233
- branch = REPO.active_branch.name
234
- REPO.index.add([req_git_path, sta_git_path])
235
- commit = REPO.index.commit(f"Add {model} to eval requests/status.")
236
- # REPO.index.add([sta_git_path])
237
- # commit = REPO.index.commit(f"Add {model} to eval status")
238
- REPO.remotes.origin.pull(branch)
239
- REPO.remotes.origin.push(branch)
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
  return styled_message(
242
  "Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."
 
5
  from huggingface_hub import ModelCard, snapshot_download
6
 
7
  from src.display.formatting import styled_error, styled_message, styled_warning
8
+ from src.envs import API, EVAL_REQUESTS_PATH, DYNAMIC_INFO_PATH, DYNAMIC_INFO_FILE_PATH, DYNAMIC_INFO_REPO, H4_TOKEN, QUEUE_REPO, RATE_LIMIT_PERIOD, RATE_LIMIT_QUOTA, REPO, GIT_REQUESTS_PATH, GIT_STATUS_PATH, GLOBAL_COND
9
  from src.leaderboard.filter_models import DO_NOT_SUBMIT_MODELS
10
  from src.submission.check_validity import (
11
  already_submitted_models,
 
220
  sta_out_path = f"{OUT_DIR}/{model_path}_eval_request_{private}_{quant_type}_{precision}_{weight_dtype}_{compute_dtype}.json"
221
  sta_git_path = "/".join(sta_out_path.split('/')[1:])
222
 
 
 
 
 
 
223
  with open(req_out_path, "w") as f:
224
  f.write(json.dumps(eval_entry, indent=4))
225
  with open(sta_out_path, "w") as f:
226
  f.write(json.dumps(eval_entry, indent=4))
227
 
228
+
229
+ print("Uploading eval file")
230
+ try:
231
+ print("git-push get lock..............")
232
+ GLOBAL_COND.acquire()
233
+ REPO.remotes.origin.pull(branch)
234
+ REPO.remotes.origin.push(branch)
235
+
236
+ REPO.index.remove("requests", False, r=True)
237
+
238
+ branch = REPO.active_branch.name
239
+ REPO.index.add([req_git_path, sta_git_path])
240
+ commit = REPO.index.commit(f"Add {model} to eval requests/status.")
241
+
242
+ print("git-push release lock..............")
243
+ GLOBAL_COND.release()
244
+ except:
245
+ print("git-push error........")
246
+ GLOBAL_COND.release()
247
 
248
  return styled_message(
249
  "Your request has been submitted to the evaluation queue!\nPlease wait for up to an hour for the model to show in the PENDING list."