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 (draft) #2600

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
98 changes: 98 additions & 0 deletions .github/workflows/update-inference-types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Update Inference Types

on:
workflow_dispatch:
push:
branches:
- add-workflow-update-inference-types

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/package.json
- name: Install dependencies
run: pnpm install
working-directory: ./huggingface.js/packages/tasks

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

# 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.GITHUB_TOKEN }}
commit-message: Update inference types (automated commit)
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
branch: update-inferene-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.js

# 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