albertvillanova HF staff commited on
Commit
f360892
·
verified ·
1 Parent(s): 59f2d4b

Update src/submission/submit.py

Browse files
Files changed (1) hide show
  1. src/submission/submit.py +6 -15
src/submission/submit.py CHANGED
@@ -1,6 +1,6 @@
1
  import json
2
- import os
3
  from datetime import datetime, timezone
 
4
 
5
  from src.display.formatting import styled_error, styled_message, styled_warning
6
  from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
@@ -27,12 +27,6 @@ def add_new_eval(
27
  if not REQUESTED_MODELS:
28
  REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
29
 
30
- user_name = ""
31
- model_path = model
32
- if "/" in model:
33
- user_name = model.split("/")[0]
34
- model_path = model.split("/")[1]
35
-
36
  precision = precision.split(" ")[0]
37
  current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
38
 
@@ -95,24 +89,21 @@ def add_new_eval(
95
  return styled_warning("This model has been already submitted.")
96
 
97
  print("Creating eval file")
98
- OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
99
- os.makedirs(OUT_DIR, exist_ok=True)
100
- out_path = f"{OUT_DIR}/{model_path}_eval_request_False_{precision}_{weight_type}.json"
101
-
102
- with open(out_path, "w") as f:
103
- f.write(json.dumps(eval_entry))
104
 
105
  print("Uploading eval file")
106
  API.upload_file(
107
  path_or_fileobj=out_path,
108
- path_in_repo=out_path.split("eval-queue/")[1],
109
  repo_id=QUEUE_REPO,
110
  repo_type="dataset",
111
  commit_message=f"Add {model} to eval queue",
112
  )
113
 
114
  # Remove the local file
115
- os.remove(out_path)
116
 
117
  return styled_message(
118
  "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."
 
1
  import json
 
2
  from datetime import datetime, timezone
3
+ from pathlib import Path
4
 
5
  from src.display.formatting import styled_error, styled_message, styled_warning
6
  from src.envs import API, EVAL_REQUESTS_PATH, TOKEN, QUEUE_REPO
 
27
  if not REQUESTED_MODELS:
28
  REQUESTED_MODELS, USERS_TO_SUBMISSION_DATES = already_submitted_models(EVAL_REQUESTS_PATH)
29
 
 
 
 
 
 
 
30
  precision = precision.split(" ")[0]
31
  current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
32
 
 
89
  return styled_warning("This model has been already submitted.")
90
 
91
  print("Creating eval file")
92
+ out_path = Path(f"{EVAL_REQUESTS_PATH}/{model}_eval_request_False_{precision}_{weight_type}.json")
93
+ out_path.parent.mkdir(exist_ok=True, parents=True)
94
+ out_path.write_text(json.dumps(eval_entry))
 
 
 
95
 
96
  print("Uploading eval file")
97
  API.upload_file(
98
  path_or_fileobj=out_path,
99
+ path_in_repo=str(out_path.relative_to(f"{EVAL_REQUESTS_PATH}")),
100
  repo_id=QUEUE_REPO,
101
  repo_type="dataset",
102
  commit_message=f"Add {model} to eval queue",
103
  )
104
 
105
  # Remove the local file
106
+ out_path.unlink()
107
 
108
  return styled_message(
109
  "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."