Spaces:
Sleeping
title: Gradio Space CI
emoji: π€
colorFrom: gray
colorTo: gray
sdk: gradio
sdk_version: 4.18.0
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_scopes:
- read-repos
space_ci:
trusted_authors:
- clefourrier
private: auto
variables: auto
secrets:
- HF_TOKEN
hardware: cpu-basic
storage: null
Listen to Pull Requests and start ephemeral Spaces on new PRs! π
Gradio Space CI is a tool to create ephemeral Spaces for each PR opened on your Space repo. The goal is to improve developer experience by making the review process as lean as possible.
β οΈ Disclaimer: Gradio Space CI works only on public Spaces.
β‘ Quick start (4 steps)
- Update your requirements.
# requirements.txt
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.1
- Set
HF_TOKEN
as a Space secret. - Configure CI in your
README.md
.
# README.md
title: ...
emoji: ...
sdk: gradio
space_ci:
trusted_authors:
- clefourrier
secrets:
- HF_TOKEN
hardware: cpu-basic
storage: null
- Enable CI in
app.py
.
# app.py
from gradio_space_ci import enable_space_ci
enable_space_ci()
And that's it! For more details, check out the integration section.
β¨ Key features
- Listen to Pull Requests.
- Launch ephemeral Spaces on new PRs.
- When a commit is pushed to a PR, the ephemeral Space gets synchronized.
- When the PR is closed, the ephemeral Space is deleted.
- Configure ephemeral Spaces automatically
- All variables are copied from the main Space.
- Secrets are copied from the main Space, based on CI configuration.
- Hardware and storage are set, based on CI configuration.
- Only trusted authors are able to access secrets
- By default, repo owners are trusted authors
- More authors can be added in CI configuration
- untrusted authors can start ephemeral Space but without secrets or custom hardware
Want more? Please open an issue in the Community Tab! This is meant to be a community-driven implementation, enhanced by user feedback and contributions!
βοΈ Integration
Integrate Gradio Space CI in just a few steps:
1. Update your requirements.txt
If you don't have a requirements.txt
file yet, create one in your Space repo.
Add the following line to it:
# requirements.txt
gradio-space-ci @ git+https://huggingface.co/spaces/Wauplin/gradio-space-ci@0.2.1
2. Add a user token as HF_TOKEN
secret
- Go to your user settings page.
- Create a new token with write permissions.
- Go to your Space settings page.
- Add
HF_TOKEN
as a Space secret with your newly created token.
(optional) You can also define a SPACE_CI_SECRET
secret value that will be used to authenticate webhook calls. If you don't define one, a random secret value will be generated for you.
3. Configure CI in README.md
Edit the Space metadata in your README.md
file:
title: ...
sdk: gradio
sdk_version: ...
app_file: ...
space_ci:
trusted_authors:
- Wauplin
# ^ Only PRs from trusted authors are deployed in an ephemeral Space.
# Space owners are automatically trusted.
# It is possible to manually trust other authors by adding them as a list.
private: auto
# ^ Can be 'true', 'false' or 'auto'. If 'auto', the ephemeral Spaces will have same
# visibility as the main Space.
variables: auto
# ^ By default ('auto'), all variables from the main Space are copied to the ephemeral Space.
# Otherwise, you can define a key-value mapping with variables to set.
# Variables are injected as environment variable in the ephemeral Space and are public for anyone landing on the Space.
secrets:
- HF_TOKEN
# ^ A list of secrets that must be copied from the main Space to the ephemeral Spaces.
# Secrets are injected as environment variable in the ephemeral Space.
# Be careful with the 'trusted_authors' list when setting secrets.
hardware: cpu-basic
# ^ Defines which hardware to assign to the ephemeral Space.
# Can be set to 'auto' to assign the same hardware as the main Space.
# Defaults to 'cpu-basic' (free).
storage: null
# ^ Defines which storage to assign to the ephemeral Space.
# Can be set to 'auto' to assign the same storage as the main Space.
# Defaults to no storage (free).
4. Enable CI in app.py
Call enable_space_ci
in your app.py
file:
# app.py
import gradio as gr
from gradio_space_ci import enable_space_ci
enable_space_ci()
# ANY gradio app
with gr.Blocks() as demo:
...
demo.launch()
And you're done! Ephemeral Spaces will be launched for each and every PR on your repo.
π Useful links
- Demo: https://huggingface.co/spaces/Wauplin/gradio-space-ci
- README: https://huggingface.co/spaces/Wauplin/gradio-space-ci/blob/main/README.md
- Questions and feedback: https://huggingface.co/spaces/Wauplin/gradio-space-ci/discussions
- Release notes: https://huggingface.co/spaces/Wauplin/gradio-space-ci/blob/main/RELEASE.md