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

Add CI to auto-generate inference types #2600

Merged
merged 10 commits into from
Nov 18, 2024
Merged
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
96 changes: 96 additions & 0 deletions .github/workflows/update-inference-types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Update Inference Types

on:
workflow_dispatch:
schedule:
- cron: "0 3 * * *" # Every day at 3am

concurrency:
group: update-inference-types
cancel-in-progress: true

jobs:
pull_request:
runs-on: ubuntu-latest
steps:
# Setup Python
- uses: actions/checkout@v3
with:
repository: huggingface/huggingface_hub
path: ./huggingface_hub
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Setup uv
run: |
pip install --upgrade uv
- name: Install dependencies
run: uv pip install --system "huggingface_hub[dev] @ ."
working-directory: ./huggingface_hub

# Setup JS
- uses: actions/checkout@v3
with:
repository: huggingface/huggingface.js
path: huggingface.js
- uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
package_json_file: ./huggingface.js/packages/tasks-gen/package.json
- name: Install dependencies
run: pnpm install
working-directory: ./huggingface.js/packages/tasks-gen

# Generate specs
- run: pnpm run inference-codegen
working-directory: ./huggingface.js/packages/tasks-gen

# Copy Python types to huggingface_hub
- run: cp -r ./huggingface.js/packages/tasks/.python_generated/* ./huggingface_hub/src/huggingface_hub/inference/_generated/types

# Post-process
- run: make inference_update
working-directory: ./huggingface_hub
- run: make style
working-directory: ./huggingface_hub

# Check changes
- run: git status
working-directory: ./huggingface_hub

# Create or update Pull Request
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
path: ./huggingface_hub
token: ${{ secrets.TOKEN_INFERENCE_SYNC_BOT }}
commit-message: Update inference types (automated commit)
branch: update-inference-types-automated-pr
delete-branch: true
title: "[Bot] Update inference types"
body: |
This PR updates the inference types. It has been generated by running:
```sh
# Generate Python code
pnpm run inference-codegen # from @huggingface/tasks-gen

# Copy to this repository
cp -r ./huggingface.js/packages/tasks/.python_generated/* ./huggingface_hub/src/huggingface_hub/inference/_generated/types

# Clean things
make inference_update
make style
```

This PR was automatically created by the [Update Inference Types workflow](https://github.com/huggingface/huggingface_hub/blob/main/.github/update-inference-types.yml).

Make sure the changes are correct before merging.
labels: |
specs
reviewers: |
Wauplin
hanouticelina
Loading