cdminix commited on
Commit
e59f801
β€’
1 Parent(s): 4af9c19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -16
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from pathlib import Path
2
  import json
 
3
 
4
  import gradio as gr
5
  from huggingface_hub import snapshot_download
@@ -71,22 +72,27 @@ def submit_eval(model_name, model_tags, web_url, hf_url, code_url, paper_url, in
71
  "inference_details": inference_details,
72
  "status": "pending",
73
  }
74
- with open(f"{EVAL_REQUESTS_PATH}/{model_id}.json", "w") as f:
75
- json.dump(request_obj, f)
76
- API.upload_file(
77
- path_or_fileobj=f"{EVAL_REQUESTS_PATH}/{model_id}.json",
78
- path_in_repo=f"{model_id}.json",
79
- repo_id=QUEUE_REPO,
80
- repo_type="dataset",
81
- commit_message=f"Add {model_name} to evaluation queue",
82
- )
83
- API.upload_file(
84
- path_or_fileobj=f"{EVAL_REQUESTS_PATH}/{model_id}.tar.gz",
85
- path_in_repo=f"{model_id}.tar.gz",
86
- repo_id=QUEUE_REPO,
87
- repo_type="dataset",
88
- commit_message=f"Add {model_name} to evaluation queue",
89
- )
 
 
 
 
 
90
  return "Model submitted successfully πŸŽ‰"
91
 
92
 
 
1
  from pathlib import Path
2
  import json
3
+ import os
4
 
5
  import gradio as gr
6
  from huggingface_hub import snapshot_download
 
72
  "inference_details": inference_details,
73
  "status": "pending",
74
  }
75
+ try:
76
+ with open(f"{EVAL_REQUESTS_PATH}/{model_id}.json", "w") as f:
77
+ json.dump(request_obj, f)
78
+ API.upload_file(
79
+ path_or_fileobj=f"{EVAL_REQUESTS_PATH}/{model_id}.json",
80
+ path_in_repo=f"{model_id}.json",
81
+ repo_id=QUEUE_REPO,
82
+ repo_type="dataset",
83
+ commit_message=f"Add {model_name} to evaluation queue",
84
+ )
85
+ API.upload_file(
86
+ path_or_fileobj=f"{EVAL_REQUESTS_PATH}/{model_id}.tar.gz",
87
+ path_in_repo=f"{model_id}.tar.gz",
88
+ repo_id=QUEUE_REPO,
89
+ repo_type="dataset",
90
+ commit_message=f"Add {model_name} to evaluation queue",
91
+ )
92
+ except error:
93
+ os.remove(f"{EVAL_REQUESTS_PATH}/{model_id}.json")
94
+ return f"Error: {error}"
95
+
96
  return "Model submitted successfully πŸŽ‰"
97
 
98