Spaces:
Runtime error
Runtime error
Hopefully fix submission feature
Browse files
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 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 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 |
|