Spaces:
AIR-Bench
/
Running on CPU Upgrade

nan commited on
Commit
318fc6c
1 Parent(s): bb19740

feat: disable model url check for anonymous submissions

Browse files
Files changed (1) hide show
  1. 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 model_url.startswith("https://huggingface.co/"):
202
- return styled_error(
203
- f"failed to submit. Model url must be a link to a valid HuggingFace model on HuggingFace space. Illegal model url: {model_url}")
204
-
205
- # validate model card
206
- repo_id = model_url.removeprefix("https://huggingface.co/")
207
- try:
208
- card = ModelCard.load(repo_id)
209
- except EntryNotFoundError as e:
210
- print(e)
211
- return styled_error(
212
- f"failed to submit. Model url must be a link to a valid HuggingFace model on HuggingFace space. Could not get model {repo_id}")
 
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)