TheoLvs commited on
Commit
59ddf0c
·
1 Parent(s): 5fe6ea4

Avoids typo error and raise warning

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -47,10 +47,15 @@ def evaluate_model(task: str, space_url: str):
47
  if "localhost" in space_url:
48
  api_url = f"{space_url}/{task}"
49
  else:
50
- api_url = f"https://{space_url.lower().replace('/', '-')}.hf.space/{task}"
51
 
52
- # Check if the space exists, will raise an error if it doesn't
53
- api.space_info(repo_id=space_url)
 
 
 
 
 
 
54
 
55
  try:
56
  # Make API call to the space
 
47
  if "localhost" in space_url:
48
  api_url = f"{space_url}/{task}"
49
  else:
 
50
 
51
+ try:
52
+ info_space = api.space_info(repo_id=space_url)
53
+ except:
54
+ return None, None, None, gr.Warning(f"Space '{space_url}' not found, it needs to be in the format username/space-name")
55
+
56
+
57
+ host = info_space.host
58
+ api_url = f"{host}/{task}"
59
 
60
  try:
61
  # Make API call to the space