Spaces:
Runtime error
Runtime error
Fix submission error handling
Browse files
app.py
CHANGED
|
@@ -1,16 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
-
|
| 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."
|