Spaces:
Running
Running
Merge remote-tracking branch 'origin/main' into pr/7
Browse files- README.md +2 -2
- RELEASE.md +4 -0
- open_pr.py +1 -1
- src/gradio_space_ci/__init__.py +1 -1
- src/gradio_space_ci/webhook.py +6 -5
README.md
CHANGED
@@ -51,7 +51,7 @@ The goal is to improve developer experience by making the review process as lean
|
|
51 |
|
52 |
```py
|
53 |
# requirements.txt
|
54 |
-
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.
|
55 |
```
|
56 |
|
57 |
2. Set `HF_TOKEN` as a Space secret.
|
@@ -110,7 +110,7 @@ Add the following line to it:
|
|
110 |
|
111 |
```bash
|
112 |
# requirements.txt
|
113 |
-
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.
|
114 |
```
|
115 |
|
116 |
### 2. Add a user token as `HF_TOKEN` secret
|
|
|
51 |
|
52 |
```py
|
53 |
# requirements.txt
|
54 |
+
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.3
|
55 |
```
|
56 |
|
57 |
2. Set `HF_TOKEN` as a Space secret.
|
|
|
110 |
|
111 |
```bash
|
112 |
# requirements.txt
|
113 |
+
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.3
|
114 |
```
|
115 |
|
116 |
### 2. Add a user token as `HF_TOKEN` secret
|
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.
|
open_pr.py
CHANGED
@@ -61,7 +61,7 @@ def open_pr(space_id_or_url: str, oauth_token: gr.OAuthToken | None) -> str:
|
|
61 |
else:
|
62 |
requirements = ""
|
63 |
if "gradio-space-ci" not in requirements:
|
64 |
-
requirements += "\ngradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.
|
65 |
|
66 |
# 2. Configure CI in README.md
|
67 |
card = SpaceCard.load(api.hf_hub_download(repo_id=space_id, repo_type="space", filename="README.md"))
|
|
|
61 |
else:
|
62 |
requirements = ""
|
63 |
if "gradio-space-ci" not in requirements:
|
64 |
+
requirements += "\ngradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.3\n"
|
65 |
|
66 |
# 2. Configure CI in README.md
|
67 |
card = SpaceCard.load(api.hf_hub_download(repo_id=space_id, repo_type="space", filename="README.md"))
|
src/gradio_space_ci/__init__.py
CHANGED
@@ -38,4 +38,4 @@ else:
|
|
38 |
from .webhook import enable_space_ci # noqa: F401
|
39 |
|
40 |
|
41 |
-
__version__ = "0.2.
|
|
|
38 |
from .webhook import enable_space_ci # noqa: F401
|
39 |
|
40 |
|
41 |
+
__version__ = "0.2.3"
|
src/gradio_space_ci/webhook.py
CHANGED
@@ -57,6 +57,9 @@ if SPACE_ID is not None: # If running in a Space (i.e. not locally)
|
|
57 |
|
58 |
EPHEMERAL_SPACES_CONFIG: Dict[str, Any] = {}
|
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,7 +204,7 @@ background_pool = ThreadPoolExecutor(max_workers=1)
|
|
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
|
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,7 +257,7 @@ async def trigger_ci_on_pr(payload: WebhookPayload, task_queue: BackgroundTasks)
|
|
254 |
and payload.event.action == "create"
|
255 |
and payload.discussion is not None
|
256 |
and payload.discussion.isPullRequest
|
257 |
-
and payload.discussion.status
|
258 |
):
|
259 |
# A comment, is it by a command ?
|
260 |
if payload.event.scope == "discussion.comment":
|
@@ -285,9 +288,7 @@ async def trigger_ci_on_pr(payload: WebhookPayload, task_queue: BackgroundTasks)
|
|
285 |
# New repo change. Is it a commit on a PR?
|
286 |
# => loop through all PRs and check if new changes happened
|
287 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space"):
|
288 |
-
if discussion.is_pull_request and discussion.status
|
289 |
-
# If untrusted author made a modification we unset the config
|
290 |
-
handle_modification(space_id=space_id, discussion=discussion)
|
291 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
292 |
# Found a PR that is not yet synced
|
293 |
task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
|
|
|
57 |
|
58 |
EPHEMERAL_SPACES_CONFIG: Dict[str, Any] = {}
|
59 |
|
60 |
+
# Draft and open PRs are considered as active (in opposition to closed and merged PRs)
|
61 |
+
ACTIVE_PR_STATUS = ("draft", "open")
|
62 |
+
|
63 |
|
64 |
def enable_space_ci() -> None:
|
65 |
"""Enable Space CI for the current Space based on config from the README.md file.
|
|
|
204 |
def recover_after_restart(space_id: str) -> None:
|
205 |
print("Looping through PRs to check if any needs to be synced.")
|
206 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space", discussion_type="pull_request"):
|
207 |
+
if discussion.status in ACTIVE_PR_STATUS:
|
208 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
209 |
# Found a PR that is not yet synced
|
210 |
print(f"Recovery. Found an open PR that is not synced: {discussion.url}. Syncing it.")
|
|
|
257 |
and payload.event.action == "create"
|
258 |
and payload.discussion is not None
|
259 |
and payload.discussion.isPullRequest
|
260 |
+
and payload.discussion.status in ACTIVE_PR_STATUS
|
261 |
):
|
262 |
# A comment, is it by a command ?
|
263 |
if payload.event.scope == "discussion.comment":
|
|
|
288 |
# New repo change. Is it a commit on a PR?
|
289 |
# => loop through all PRs and check if new changes happened
|
290 |
for discussion in get_repo_discussions(repo_id=space_id, repo_type="space"):
|
291 |
+
if discussion.is_pull_request and discussion.status in ACTIVE_PR_STATUS:
|
|
|
|
|
292 |
if not is_pr_synced(space_id=space_id, pr_num=discussion.num):
|
293 |
# Found a PR that is not yet synced
|
294 |
task_queue.add_task(sync_ci_space, space_id=space_id, pr_num=discussion.num)
|