Skip to content

Commit

Permalink
Automatically restart spaces if they're down (#2405)
Browse files Browse the repository at this point in the history
* check and restart spaces that are down

* if no auth_token, don't break build

* add to changelog

* Update CHANGELOG.md
  • Loading branch information
aliabd authored Oct 11, 2022
1 parent 1dd4d34 commit ad2c079
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ No changes to highlight.
* When an `Image` component is set to `source="upload"`, it is now possible to drag and drop and image to replace a previously uploaded image by [@pngwn](https://github.com/pngwn) in [PR 2400](https://github.com/gradio-app/gradio/pull/2410)
* Improve documentation of the `Blocks.load()` event by [@abidlabs](https://github.com/abidlabs) in [PR 2413](https://github.com/gradio-app/gradio/pull/2413)
* Decreased latency in iterative-output demos by making the iteration asynchronous [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2409](https://github.com/gradio-app/gradio/pull/2409)
* Automatically restart spaces if they're down by [@aliabd](https://github.com/aliabd) in [PR 2405](https://github.com/gradio-app/gradio/pull/2405)

## Contributors Shoutout:
No changes to highlight.
Expand Down
10 changes: 10 additions & 0 deletions website/homepage/src/demos/restart_demos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from upload_demos import demos_by_category, upload_demo_to_space, AUTH_TOKEN, gradio_version
from gradio.networking import url_ok


for category in demos_by_category:
for demo in category["demos"]:
space_id = "gradio/" + demo["dir"]
if not url_ok(f"https://hf.space/embed/{space_id}/+"):
print(f"{space_id} was down, restarting")
upload_demo_to_space(demo_name=demo["dir"], space_id=space_id, hf_token=AUTH_TOKEN, gradio_version=gradio_version)
10 changes: 6 additions & 4 deletions website/homepage/src/demos/upload_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ def upload_demo_to_space(
)
return f"https://huggingface.co/spaces/{space_id}"

for category in demos_by_category:
for demo in category["demos"]:
space_id = "gradio/" + demo["dir"]
upload_demo_to_space(demo_name=demo["dir"], space_id=space_id, hf_token=AUTH_TOKEN, gradio_version=gradio_version)
if __name__ == "__main__":
if AUTH_TOKEN is not None:
for category in demos_by_category:
for demo in category["demos"]:
space_id = "gradio/" + demo["dir"]
upload_demo_to_space(demo_name=demo["dir"], space_id=space_id, hf_token=AUTH_TOKEN, gradio_version=gradio_version)

0 comments on commit ad2c079

Please sign in to comment.