Wauplin HF staff commited on
Commit
3f40ea3
1 Parent(s): f176410

fix if repo already deleted

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -18,6 +18,7 @@ from huggingface_hub.repocard import RepoCard
18
  from requests import HTTPError
19
  from gradio_webhooks import GradioWebhookApp, WebhookPayload
20
  from huggingface_hub import login
 
21
  from ui import generate_ui
22
  from database import is_space_registered
23
 
@@ -177,7 +178,10 @@ def sync_ci_space(space_id: str, pr_num: int, private: bool) -> None:
177
  def delete_ci_space(space_id: str, pr_num: int) -> None:
178
  # Delete
179
  ci_space_id = _get_ci_space_id(space_id=space_id, pr_num=pr_num)
180
- delete_repo(repo_id=ci_space_id, repo_type="space")
 
 
 
181
 
182
  # Notify about deletion
183
  notify_pr(space_id=space_id, pr_num=pr_num, action="delete")
 
18
  from requests import HTTPError
19
  from gradio_webhooks import GradioWebhookApp, WebhookPayload
20
  from huggingface_hub import login
21
+ from huggingface_hub.utils import RepositoryNotFoundError
22
  from ui import generate_ui
23
  from database import is_space_registered
24
 
 
178
  def delete_ci_space(space_id: str, pr_num: int) -> None:
179
  # Delete
180
  ci_space_id = _get_ci_space_id(space_id=space_id, pr_num=pr_num)
181
+ try:
182
+ delete_repo(repo_id=ci_space_id, repo_type="space")
183
+ except RepositoryNotFoundError:
184
+ pass
185
 
186
  # Notify about deletion
187
  notify_pr(space_id=space_id, pr_num=pr_num, action="delete")