ci: use HF cache #5823
Workflow file for this run
This file contains 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: CPU tests | |
on: | |
push: | |
branches: [main, wip] | |
pull_request: | |
branches: [main, wip] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
defaults: | |
run: | |
shell: bash | |
env: | |
HF_HOME: ~/.cache/huggingface # Define HF_HOME for caching | |
TRANSFORMERS_CACHE: ~/.cache/huggingface/transformers | |
DATASETS_CACHE: ~/.cache/huggingface/datasets | |
HF_DATASETS_CACHE: ~/.cache/huggingface/datasets | |
jobs: | |
testing-imports: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ "ubuntu-22.04", "macOS-14", "windows-2022" ] | |
python-version: [ "3.10" ] | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install minimal dependencies | |
run: | | |
pip install . | |
pip list | |
# Add caching for HF models and datasets | |
- name: Cache HF files | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/huggingface | |
key: ${{ runner.os }}-huggingface-${{ hashFiles('**/pyproject.toml') }} | |
restore-keys: | | |
${{ runner.os }}-huggingface- | |
- name: Testing package imports | |
# make sure all modules are still importable with only the minimal dependencies available | |
run: | | |
modules=$( | |
find litgpt -type f -name "*.py" | \ | |
sed 's/\.py$//' | sed 's/\//./g' | \ | |
sed 's/.__init__//g' | xargs -I {} echo "import {};" | |
) | |
echo "$modules" | |
python -c "$modules" | |
pytester: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-22.04"] | |
python-version: ["3.9", "3.10", "3.11"] | |
include: | |
- {os: "macOS-14", python-version: "3.9"} # without Thunder | |
- {os: "windows-2022", python-version: "3.9"} # without Thunder | |
timeout-minutes: 25 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: | | |
pyproject.toml | |
- name: Install dependencies | |
run: | | |
pip install '.[extra,all,test]' | |
pip list | |
- name: Run tests | |
run: pytest -v litgpt/ tests/ --timeout 120 | |
testing-guardian: | |
runs-on: ubuntu-latest | |
needs: [pytester, testing-imports] | |
if: always() | |
steps: | |
- run: echo "${{ needs.pytester.result }}" | |
- name: failing... | |
if: needs.pytester.result == 'failure' | |
run: exit 1 | |
- name: cancelled or skipped... | |
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result) | |
timeout-minutes: 1 | |
run: sleep 90 |