Multi-Backend Latent Space Analysis Support and transformers v5 compatibility
#131
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Stale Stubs and Type Checks | |
| on: | |
| push: | |
| branches: [main, "release/*", "bugfix/*", "feature/*"] | |
| paths: | |
| - "setup.*" | |
| - "requirements.txt" | |
| - "pyproject.toml" | |
| - "src/**" | |
| - "requirements/**" | |
| - "scripts/generate_op_stubs.py" | |
| - ".github/workflows/type-check.yml" | |
| # Exclude documentation-only files from triggering | |
| - "!docs/**" | |
| - "!**/*.md" | |
| - "!**/*.rst" | |
| - "!mkdocs.yml" | |
| - "!**/CHANGELOG.md" | |
| - "!**/CODE_OF_CONDUCT.md" | |
| - "!**/CONTRIBUTING.md" | |
| - "!**/LICENSE*" | |
| - "!scripts/**" | |
| pull_request: | |
| branches: [main, "release/*", "bugfix/*", "feature/*"] | |
| types: [opened, reopened, ready_for_review, synchronize] | |
| paths: | |
| - "setup.*" | |
| - "requirements.txt" | |
| - "pyproject.toml" | |
| - "src/**" | |
| - "requirements/**" | |
| - "scripts/generate_op_stubs.py" | |
| - ".github/workflows/type-check.yml" | |
| # Exclude documentation-only files from triggering | |
| - "!docs/**" | |
| - "!**/*.md" | |
| - "!**/*.rst" | |
| - "!mkdocs.yml" | |
| - "!**/CHANGELOG.md" | |
| - "!**/CODE_OF_CONDUCT.md" | |
| - "!**/CONTRIBUTING.md" | |
| - "!**/LICENSE*" | |
| - "!scripts/**" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} | |
| cancel-in-progress: ${{ ! (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }} | |
| jobs: | |
| type-check: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 30 | |
| env: | |
| IT_USE_CT_COMMIT_PIN: "1" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Reset caching | |
| id: set_time_period | |
| run: | | |
| python -c "import time; days = time.time() / 60 / 60 / 24; print(f'TIME_PERIOD=d{int(days / 7) * 7}')" >> $GITHUB_OUTPUT | |
| - name: Get pip cache dir | |
| id: pip-cache | |
| shell: bash | |
| run: | | |
| echo "PIP_CACHE_DIR=$(pip cache dir)" >> $GITHUB_ENV | |
| - name: pip cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.PIP_CACHE_DIR }}/wheels | |
| key: ubuntu-22.04-pip-wheels-${{ steps.set_time_period.outputs.TIME_PERIOD }}-py3.13-${{ hashFiles('requirements/ci/requirements.txt') }} | |
| restore-keys: | | |
| ubuntu-22.04-pip-wheels-${{ steps.set_time_period.outputs.TIME_PERIOD }}-py3.13- | |
| - name: Install CI dependencies | |
| uses: ./.github/actions/install-ci-dependencies | |
| with: | |
| apply_post_upgrades: ${{ vars.APPLY_POST_UPGRADES || 'false' }} | |
| - name: Check type stubs are up to date | |
| id: check_stubs | |
| continue-on-error: true | |
| shell: bash | |
| run: | | |
| # Make a backup of current stubs | |
| cp src/interpretune/__init__.pyi src/interpretune/__init__.pyi.backup | |
| # Regenerate stubs | |
| python scripts/generate_op_stubs.py | |
| # Check if stubs changed using our shared action | |
| echo "stub_check_step=true" >> $GITHUB_OUTPUT | |
| - name: Check for stub differences | |
| id: stub_diff | |
| uses: ./.github/actions/check-file-diffs | |
| with: | |
| compare_paths: "src/interpretune/__init__.pyi" | |
| patch_path: "stubs_diff.patch" | |
| error_message: "Type stubs are stale and need to be regenerated with: python scripts/generate_op_stubs.py" | |
| - name: Upload stub diff (if present) | |
| if: steps.stub_diff.outputs.changed == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: type-stubs-diff | |
| path: stubs_diff.patch | |
| - name: Run pyright type check | |
| shell: bash | |
| run: | | |
| pyright -p pyproject.toml | |
| - name: Fail workflow if stubs are stale | |
| if: steps.stub_diff.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| echo "::error::Type stubs are stale. Please run 'python scripts/generate_op_stubs.py' and commit the updated __init__.pyi file." | |
| exit 1 |