Spaces:
Runtime error
Runtime error
run recovery in background
Browse files
src/gradio_space_ci/webhook.py
CHANGED
|
@@ -179,8 +179,9 @@ def configure_space_ci(
|
|
| 179 |
server.add_webhook()(trigger_ci_on_pr)
|
| 180 |
configure_webhook_on_hub()
|
| 181 |
|
| 182 |
-
# Recover missed webhooks
|
| 183 |
-
recover_after_restart
|
|
|
|
| 184 |
return server
|
| 185 |
|
| 186 |
|
|
@@ -314,6 +315,10 @@ def is_pr_synced(space_id: str, pr_num: int) -> bool:
|
|
| 314 |
|
| 315 |
def sync_ci_space(space_id: str, pr_num: int) -> None:
|
| 316 |
print(f"New task: sync ephemeral env for {space_id} (PR {pr_num})")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
ci_space_id = _get_ci_space_id(space_id=space_id, pr_num=pr_num)
|
| 318 |
|
| 319 |
# Create a temporary space for CI if didn't exist
|
|
|
|
| 179 |
server.add_webhook()(trigger_ci_on_pr)
|
| 180 |
configure_webhook_on_hub()
|
| 181 |
|
| 182 |
+
# Recover missed webhooks (loop through PRs in the background)
|
| 183 |
+
background_pool.submit(recover_after_restart, space_id=SPACE_ID)
|
| 184 |
+
|
| 185 |
return server
|
| 186 |
|
| 187 |
|
|
|
|
| 315 |
|
| 316 |
def sync_ci_space(space_id: str, pr_num: int) -> None:
|
| 317 |
print(f"New task: sync ephemeral env for {space_id} (PR {pr_num})")
|
| 318 |
+
if is_pr_synced(space_id=space_id, pr_num=pr_num):
|
| 319 |
+
print("Already synced. Nothing to do.")
|
| 320 |
+
return
|
| 321 |
+
|
| 322 |
ci_space_id = _get_ci_space_id(space_id=space_id, pr_num=pr_num)
|
| 323 |
|
| 324 |
# Create a temporary space for CI if didn't exist
|