devingulliver commited on
Commit
0fade42
1 Parent(s): 59d0aa9

Fix submission error handling

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,16 +1,16 @@
1
  import os
2
  import requests
3
- from huggingface_hub import hf_hub_download
4
  import gradio as gr
5
 
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 FileNotFoundError:
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."
 
1
  import os
2
  import requests
3
+ import huggingface_hub
4
  import gradio as gr
5
 
6
  webhook_url = os.environ.get("WEBHOOK_URL")
7
 
8
  def submit_model(name):
9
  try:
10
+ huggingface_hub.hf_hub_download(repo_id=name, filename="config.json") # sanity check input
11
+ except huggingface_hub.utils._errors.FileNotFoundError:
12
  return "# ERROR: Model does not have a config.json file!"
13
+ except huggingface_hub.utils._errors.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."