diff --git a/.changeset/silent-pens-decide.md b/.changeset/silent-pens-decide.md new file mode 100644 index 000000000000..7d39aaf4d02c --- /dev/null +++ b/.changeset/silent-pens-decide.md @@ -0,0 +1,6 @@ +--- +"gradio": minor +"website": minor +--- + +feat:Move scripts from old website to CI diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index d4914ba30f69..1fdc8637872e 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -1,6 +1,9 @@ name: Build PR Artifacts on: + push: + branches: + - main pull_request: branches: - main @@ -35,9 +38,13 @@ jobs: - name: Get PR Number id: get_pr_number run: | - python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt - echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_OUTPUT echo "GRADIO_VERSION=$(python -c 'import requests;print(requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"])')" >> $GITHUB_OUTPUT + if ${{ github.event_name == 'pull_request' }}; then + python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt + echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_OUTPUT + else + echo "PR_NUMBER='main'" >> $GITHUB_OUTPUT + fi - name: Build pr package run: | echo ${{ steps.get_pr_number.outputs.GRADIO_VERSION }} > gradio/version.txt diff --git a/.github/workflows/build-version-docs.yml b/.github/workflows/build-version-docs.yml deleted file mode 100644 index 58c71ecf598b..000000000000 --- a/.github/workflows/build-version-docs.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflow will build gradio and create the version's docs file when a new stable version has been released - -name: Create Version's Docs -on: - workflow_dispatch: - pull_request: - types: closed - branches: - - main - paths: - - 'gradio/version.txt' - - -jobs: - check-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install requirements - run: python -m pip install -r website/homepage/requirements.txt - - name: Check new pypi version - run: cd website && python check_version.py - build-docs: - needs: check-version - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install requirements - run: python -m pip install -r website/homepage/requirements.txt - - name: Pin httpx, httpcore, and h11 - run: pip install h11==0.12.0 httpcore==0.15.0 httpx==0.23.0 - - name: Wait 5 min - run: sleep 300 - - name: Install gradio - run: python -m pip install gradio==$(cat gradio/version.txt) - - name: Build Docs - run: | - export HF_AUTH_TOKEN=${{ secrets.HF_AUTH_TOKEN }} - cd website/homepage && python build-version-docs.py \ No newline at end of file diff --git a/.github/workflows/deploy-pr-to-spaces.yml b/.github/workflows/deploy-pr-to-spaces.yml index 5e1d201f8cff..bd9bac7c7891 100644 --- a/.github/workflows/deploy-pr-to-spaces.yml +++ b/.github/workflows/deploy-pr-to-spaces.yml @@ -14,9 +14,6 @@ jobs: sha: ${{ steps.set-outputs.outputs.gh_sha }} gradio_version: ${{ steps.set-outputs.outputs.gradio_version }} runs-on: ubuntu-latest - if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' steps: - uses: actions/checkout@v3 - name: Install Python @@ -51,6 +48,9 @@ jobs: - run: unzip all_demos.zip -d all_demos - run: cp -R all_demos/* demo/all_demos - name: Upload demo to spaces + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' id: upload-demo run: | python scripts/upload_demo_to_space.py all_demos \ @@ -58,6 +58,14 @@ jobs: ${{ secrets.SPACES_DEPLOY_TOKEN }} \ --gradio-version ${{ steps.set-outputs.outputs.gradio_version }} > url.txt echo "SPACE_URL=$(cat url.txt)" >> $GITHUB_OUTPUT + - name: Upload website demos + if: > + github.event.workflow_run.event == 'push' && + github.event.workflow_run.conclusion == 'success' + run: | + python scripts/upload_website_demos.py --AUTH_TOKEN ${{ secrets.SPACES_DEPLOY_TOKEN }} \ + --WHEEL_URL https://gradio-builds.s3.amazonaws.com/${{ steps.set-outputs.outputs.gh_sha }}/ \ + comment-spaces-success: uses: "./.github/workflows/comment-queue.yml" needs: [deploy-current-pr] diff --git a/demo/duplicatebutton_component/run.ipynb b/demo/duplicatebutton_component/run.ipynb new file mode 100644 index 000000000000..712304fbee66 --- /dev/null +++ b/demo/duplicatebutton_component/run.ipynb @@ -0,0 +1 @@ +{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: duplicatebutton_component"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.DuplicateButton()\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file diff --git a/demo/duplicatebutton_component/run.py b/demo/duplicatebutton_component/run.py new file mode 100644 index 000000000000..f8f314684737 --- /dev/null +++ b/demo/duplicatebutton_component/run.py @@ -0,0 +1,6 @@ +import gradio as gr + +with gr.Blocks() as demo: + gr.DuplicateButton() + +demo.launch() \ No newline at end of file diff --git a/demo/html_component/run.ipynb b/demo/html_component/run.ipynb index 72b8759d00e1..7f7f14697b6a 100644 --- a/demo/html_component/run.ipynb +++ b/demo/html_component/run.ipynb @@ -1 +1 @@ -{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: html_component"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.HTML(value=\"
Gradio Docs Readers:
\")\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file +{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: html_component"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.HTML(value=\"This example was written in HTML
\")\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file diff --git a/demo/html_component/run.py b/demo/html_component/run.py index 3b60e476cf64..c3f533d9c499 100644 --- a/demo/html_component/run.py +++ b/demo/html_component/run.py @@ -1,6 +1,6 @@ import gradio as gr with gr.Blocks() as demo: - gr.HTML(value="Gradio Docs Readers:
") + gr.HTML(value="This example was written in HTML
") demo.launch() \ No newline at end of file diff --git a/demo/loginbutton_component/requirements.txt b/demo/loginbutton_component/requirements.txt new file mode 100644 index 000000000000..f7359a07d4b7 --- /dev/null +++ b/demo/loginbutton_component/requirements.txt @@ -0,0 +1 @@ +gradio[oauth] \ No newline at end of file diff --git a/demo/loginbutton_component/run.ipynb b/demo/loginbutton_component/run.ipynb new file mode 100644 index 000000000000..54acb9264942 --- /dev/null +++ b/demo/loginbutton_component/run.ipynb @@ -0,0 +1 @@ +{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: loginbutton_component"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio gradio[oauth]"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.LoginButton()\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file diff --git a/demo/loginbutton_component/run.py b/demo/loginbutton_component/run.py new file mode 100644 index 000000000000..51a200c2eddd --- /dev/null +++ b/demo/loginbutton_component/run.py @@ -0,0 +1,6 @@ +import gradio as gr + +with gr.Blocks() as demo: + gr.LoginButton() + +demo.launch() \ No newline at end of file diff --git a/demo/logoutbutton_component/requirements.txt b/demo/logoutbutton_component/requirements.txt new file mode 100644 index 000000000000..f7359a07d4b7 --- /dev/null +++ b/demo/logoutbutton_component/requirements.txt @@ -0,0 +1 @@ +gradio[oauth] \ No newline at end of file diff --git a/demo/logoutbutton_component/run.ipynb b/demo/logoutbutton_component/run.ipynb new file mode 100644 index 000000000000..e42b7e828358 --- /dev/null +++ b/demo/logoutbutton_component/run.ipynb @@ -0,0 +1 @@ +{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: logoutbutton_component"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio gradio[oauth]"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr \n", "\n", "with gr.Blocks() as demo:\n", " gr.LogoutButton()\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} \ No newline at end of file diff --git a/demo/logoutbutton_component/run.py b/demo/logoutbutton_component/run.py new file mode 100644 index 000000000000..05e04c6e8d36 --- /dev/null +++ b/demo/logoutbutton_component/run.py @@ -0,0 +1,6 @@ +import gradio as gr + +with gr.Blocks() as demo: + gr.LogoutButton() + +demo.launch() \ No newline at end of file diff --git a/gradio/ipython_ext.py b/gradio/ipython_ext.py index 7d998ce4075a..b6bb8063930f 100644 --- a/gradio/ipython_ext.py +++ b/gradio/ipython_ext.py @@ -42,7 +42,7 @@ def current_cell(self): @property def running_app(self) -> App: assert self.running_demo.server - return self.running_demo.server.running_app + return self.running_demo.server.running_app # type: ignore @property def running_demo(self): diff --git a/gradio/networking.py b/gradio/networking.py index 7b0045139ae9..b216f0191e24 100644 --- a/gradio/networking.py +++ b/gradio/networking.py @@ -43,7 +43,6 @@ class Server(uvicorn.Server): def __init__( self, config: Config, reloader: SourceFileReloader | None = None ) -> None: - assert isinstance(config.app, App) self.running_app = config.app super().__init__(config) self.reloader = reloader diff --git a/guides/08_other-tutorials/how-to-use-3D-model-component.md b/guides/08_other-tutorials/how-to-use-3D-model-component.md index 0c170553ad24..3e14ee763ba2 100644 --- a/guides/08_other-tutorials/how-to-use-3D-model-component.md +++ b/guides/08_other-tutorials/how-to-use-3D-model-component.md @@ -1,6 +1,6 @@ # How to Use the 3D Model Component -Related spaces: https://huggingface.co/spaces/dawood/Model3D, https://huggingface.co/spaces/radames/PIFu-Clothed-Human-Digitization, https://huggingface.co/spaces/radames/dpt-depth-estimation-3d-obj +Related spaces: https://huggingface.co/spaces/gradio/Model3D, https://huggingface.co/spaces/gradio/PIFu-Clothed-Human-Digitization, https://huggingface.co/spaces/gradio/dpt-depth-estimation-3d-obj Tags: VISION, IMAGE ## Introduction @@ -9,7 +9,7 @@ Tags: VISION, IMAGE This guide will show you how to build a demo for your 3D image model in a few lines of code; like the one below. Play around with 3D object by clicking around, dragging and zooming: -