Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a pypi release action for the gradio python client #3743

Merged
merged 26 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/deploy-client-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will upload a Python Package when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Gradio Client Python Package

on:
workflow_dispatch:
pull_request:
types: closed
branches:
- main
paths:
- 'client/python/gradio_client/version.txt'

jobs:
deploy:
if: github.event.pull_request.merged == true || github.event.action == ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Check new pypi version
run: python client/python/scripts/check_pypi.py
- name: Build pypi package
run: |
client/python/scripts/build_pypi.sh
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that what we are already doing? We're providing the exact hash: 27b31702a0e7fc50959f5ad993c78deac1bdfc29

with:
user: aabid93
password: ${{ secrets.PYPI_GRADIO_CLIENT_TOKEN }}
packages_dir: client/python/dist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually thought the same but that parameter must have gotten renamed. The correct parameter (at least for this version of the GH action) is packages_dir. You can see the error when I try using packages-dir here: https://github.com/abidlabs/gradio/actions/runs/4603068339

2 changes: 1 addition & 1 deletion client/python/gradio_client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.7
0.0.6b10
9 changes: 9 additions & 0 deletions client/python/scripts/build_pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

cd "$(dirname ${0})/.."

python3 -m pip install build
rm -rf dist/*
rm -rf build/*
python3 -m build
16 changes: 16 additions & 0 deletions client/python/scripts/check_pypi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import json
import sys
import urllib.request
from pathlib import Path

version_file = Path(__file__).parent.parent / "gradio_client" / "version.txt"
version = version_file.read_text(encoding="utf8").strip()

with urllib.request.urlopen("https://pypi.org/pypi/gradio_client/json") as url:
releases = json.load(url)["releases"]

if version in releases:
print(f"Version {version} already exists on PyPI")
sys.exit(1)
else:
print(f"Version {version} does not exist on PyPI")
6 changes: 3 additions & 3 deletions client/python/scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
cd "$(dirname ${0})/.."

echo "Formatting the client library.. Our style follows the Black code style."
ruff --fix test gradio_client
black test gradio_client
ruff --fix .
black .

echo "Type checking the client library with pyright"
pyright gradio_client/*.py
pyright gradio_client/*.py
8 changes: 0 additions & 8 deletions client/python/scripts/upload_pypi.sh

This file was deleted.