Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
feat: disable model url check for anonymous submissions
Browse files- src/utils.py +13 -12
src/utils.py
CHANGED
|
@@ -198,18 +198,19 @@ def submit_results(filepath: str, model: str, model_url: str, version: str = "AI
|
|
| 198 |
return styled_error("failed to submit. Model name can not be empty.")
|
| 199 |
|
| 200 |
# validate model url
|
| 201 |
-
if not
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
| 213 |
|
| 214 |
# rename the uploaded file
|
| 215 |
input_fp = Path(filepath)
|
|
|
|
| 198 |
return styled_error("failed to submit. Model name can not be empty.")
|
| 199 |
|
| 200 |
# validate model url
|
| 201 |
+
if not is_anonymous:
|
| 202 |
+
if not model_url.startswith("https://") and not model_url.startswith("http://"):
|
| 203 |
+
# TODO: retrieve the model page and find the model name on the page
|
| 204 |
+
return styled_error(
|
| 205 |
+
f"failed to submit. Model url must start with `https://` or `http://`. Illegal model url: {model_url}")
|
| 206 |
+
if model_url.startswith("https://huggingface.co/"):
|
| 207 |
+
# validate model card
|
| 208 |
+
repo_id = model_url.removeprefix("https://huggingface.co/")
|
| 209 |
+
try:
|
| 210 |
+
card = ModelCard.load(repo_id)
|
| 211 |
+
except EntryNotFoundError as e:
|
| 212 |
+
return styled_error(
|
| 213 |
+
f"failed to submit. Model url must be a link to a valid HuggingFace model on HuggingFace space. Could not get model {repo_id}")
|
| 214 |
|
| 215 |
# rename the uploaded file
|
| 216 |
input_fp = Path(filepath)
|