Fix submission feature
Browse files
app.py
CHANGED
@@ -8,17 +8,23 @@ webhook_url = os.environ.get("WEBHOOK_URL")
|
|
8 |
def submit_model(name):
|
9 |
try:
|
10 |
hf_hub_download(repo_id=name, filename="config.json") # sanity check input
|
11 |
-
except
|
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 |
|
|
|
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."
|
17 |
+
except Exception as e:
|
18 |
+
print(e)
|
19 |
+
return "ERROR: Unexpected error. Please try again later."
|
20 |
|
21 |
try:
|
22 |
result = requests.post(webhook_url, json={"content":name})
|
23 |
except requests.exceptions.HTTPError:
|
24 |
return "# ERROR: Network error while contacting queue. Please try again in a few minutes."
|
25 |
+
except Exception as e:
|
26 |
+
print(e)
|
27 |
+
return "ERROR: Unexpected error. Please try again later."
|
28 |
|
29 |
return "# SUCCESS: Please wait up to 24 hours for your model to be added to the queue."
|
30 |
|