devingulliver commited on
Commit
7c67606
1 Parent(s): 2bd6997

Hopefully fix submission feature

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -6,23 +6,19 @@ import gradio as gr
6
  webhook_url = os.environ.get("WEBHOOK_URL")
7
 
8
  def submit_model(name):
9
- #try:
10
- print(name)
11
- hf_hub_download(repo_id=name, filename="config.json") # sanity check input
12
- #except EntryNotFoundError:
13
- # return "# ERROR: Model does not have a config.json file!"
14
- #except RepositoryNotFoundError:
15
- # return "# ERROR: Model could not be found on the Hugging Face Hub!"
16
- #except:
17
- # return "# ERROR: Unexpected error. Please try again later."
18
- #
19
- #try:
20
- result = requests.post(webhook_url, json={"content":name})
21
- #result.raise_for_status()
22
- #except requests.exceptions.HTTPError:
23
- # return "# ERROR: Could not contact queue. Please try again in a few minutes."
24
- #except:
25
- # return "# ERROR: Unexpected error. Please try again later."
26
 
27
  return "# SUCCESS: Please wait up to 24 hours for your model to be added to the queue."
28
 
 
6
  webhook_url = os.environ.get("WEBHOOK_URL")
7
 
8
  def submit_model(name):
9
+ try:
10
+ hf_hub_download(repo_id=name, filename="config.json") # sanity check input
11
+ except EntryNotFoundError:
12
+ return "# ERROR: Model does not have a config.json file!"
13
+ except RepositoryNotFoundError:
14
+ return "# ERROR: Model could not be found on the Hugging Face Hub!"
15
+ except requests.exceptions.HTTPError:
16
+ return "# ERROR: Network error while validating model. Please try again later."
17
+
18
+ try:
19
+ result = requests.post(webhook_url, json={"content":name})
20
+ except requests.exceptions.HTTPError:
21
+ return "# ERROR: Network error while contacting queue. Please try again in a few minutes."
 
 
 
 
22
 
23
  return "# SUCCESS: Please wait up to 24 hours for your model to be added to the queue."
24