Spaces:
Runtime error
Runtime error
Deploy on draft PRs
Browse files- RELEASE.md +4 -0
- src/gradio_space_ci/webhook.py +6 -3
RELEASE.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
## 0.2.2
|
| 2 |
|
| 3 |
- Install `huggingface_hub>=0.21.1` now that 0.21 have been released.
|
|
|
|
| 1 |
+
## 0.2.3
|
| 2 |
+
|
| 3 |
+
- Deploy on "draft" PRs as well, not just "open" PRs.
|
| 4 |
+
|
| 5 |
## 0.2.2
|
| 6 |
|
| 7 |
- Install `huggingface_hub>=0.21.1` now that 0.21 have been released.
|
src/gradio_space_ci/webhook.py
CHANGED
|
@@ -54,6 +54,9 @@ if SPACE_ID is not None: # If running in a Space (i.e. not locally)
|
|
| 54 |
|
| 55 |
EPHEMERAL_SPACES_CONFIG: Dict[str, Any] = {}
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
def enable_space_ci() -> None:
|
| 59 |
"""Enable Space CI for the current Space based on config from the README.md file.
|
|
@@ -198,7 +201,7 @@ background_pool = ThreadPoolExecutor(max_workers=1)
|
|
| 198 |
def recover_after_restart(space_id: str) -> None:
|
| 199 |
print("Looping through PRs to check if any needs to be synced.")
|
| 200 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space", discussion_type="pull_request"):
|
| 201 |
-
if discussion.status
|
| 202 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
| 203 |
# Found a PR that is not yet synced
|
| 204 |
print(f"Recovery. Found an open PR that is not synced: {discussion.url}. Syncing it.")
|
|
@@ -251,7 +254,7 @@ async def trigger_ci_on_pr(payload: WebhookPayload, task_queue: BackgroundTasks)
|
|
| 251 |
and payload.event.action == "create"
|
| 252 |
and payload.discussion is not None
|
| 253 |
and payload.discussion.isPullRequest
|
| 254 |
-
and payload.discussion.status
|
| 255 |
):
|
| 256 |
if not is_pr_synced(space_id=space_id, pr_num=payload.discussion.num):
|
| 257 |
# New PR! Sync task scheduled
|
|
@@ -278,7 +281,7 @@ async def trigger_ci_on_pr(payload: WebhookPayload, task_queue: BackgroundTasks)
|
|
| 278 |
# New repo change. Is it a commit on a PR?
|
| 279 |
# => loop through all PRs and check if new changes happened
|
| 280 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space"):
|
| 281 |
-
if discussion.is_pull_request and discussion.status
|
| 282 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
| 283 |
# Found a PR that is not yet synced
|
| 284 |
task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
|
|
|
|
| 54 |
|
| 55 |
EPHEMERAL_SPACES_CONFIG: Dict[str, Any] = {}
|
| 56 |
|
| 57 |
+
# Draft and open PRs are considered as active (in opposition to closed and merged PRs)
|
| 58 |
+
ACTIVE_PR_STATUS = ("draft", "open")
|
| 59 |
+
|
| 60 |
|
| 61 |
def enable_space_ci() -> None:
|
| 62 |
"""Enable Space CI for the current Space based on config from the README.md file.
|
|
|
|
| 201 |
def recover_after_restart(space_id: str) -> None:
|
| 202 |
print("Looping through PRs to check if any needs to be synced.")
|
| 203 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space", discussion_type="pull_request"):
|
| 204 |
+
if discussion.status in ACTIVE_PR_STATUS:
|
| 205 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
| 206 |
# Found a PR that is not yet synced
|
| 207 |
print(f"Recovery. Found an open PR that is not synced: {discussion.url}. Syncing it.")
|
|
|
|
| 254 |
and payload.event.action == "create"
|
| 255 |
and payload.discussion is not None
|
| 256 |
and payload.discussion.isPullRequest
|
| 257 |
+
and payload.discussion.status in ACTIVE_PR_STATUS
|
| 258 |
):
|
| 259 |
if not is_pr_synced(space_id=space_id, pr_num=payload.discussion.num):
|
| 260 |
# New PR! Sync task scheduled
|
|
|
|
| 281 |
# New repo change. Is it a commit on a PR?
|
| 282 |
# => loop through all PRs and check if new changes happened
|
| 283 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space"):
|
| 284 |
+
if discussion.is_pull_request and discussion.status in ACTIVE_PR_STATUS:
|
| 285 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
| 286 |
# Found a PR that is not yet synced
|
| 287 |
task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
|