Automatically restart spaces if they're down (#2405)

* check and restart spaces that are down

* if no auth_token, don't break build

* add to changelog

* Update CHANGELOG.md
This commit is contained in:
Ali Abdalla 2022-10-10 18:42:59 -07:00 committed by GitHub
parent 1dd4d34933
commit ad2c0790b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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)