Skip to content

Commit

Permalink
Uv workflow improvements (rasbt#531)
Browse files Browse the repository at this point in the history
* Uv workflow improvements

* Uv workflow improvements

* linter improvements

* pytproject.toml fixes

* pytproject.toml fixes

* pytproject.toml fixes

* pytproject.toml fixes

* pytproject.toml fixes

* pytproject.toml fixes

* windows fixes

* windows fixes

* windows fixes

* windows fixes

* windows fixes

* windows fixes

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix

* win32 fix
  • Loading branch information
rasbt authored Feb 16, 2025
1 parent 29353c7 commit a08d7aa
Show file tree
Hide file tree
Showing 29 changed files with 372 additions and 311 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/basic-tests-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,24 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install pytest nbval
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
uv pip install pytest
uv add pytest-ruff nbval
- name: Test Selected Python Scripts
run: |
source .venv/bin/activate
pytest setup/02_installing-python-libraries/tests.py
pytest ch04/01_main-chapter-code/tests.py
pytest ch05/01_main-chapter-code/tests.py
pytest ch05/07_gpt_to_llama/tests/tests.py
pytest ch06/01_main-chapter-code/tests.py
pytest --ruff setup/02_installing-python-libraries/tests.py
pytest --ruff ch04/01_main-chapter-code/tests.py
pytest --ruff ch05/01_main-chapter-code/tests.py
pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
pytest --ruff ch06/01_main-chapter-code/tests.py
- name: Validate Selected Jupyter Notebooks
run: |
source .venv/bin/activate
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
27 changes: 12 additions & 15 deletions .github/workflows/basic-tests-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,24 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install pytest nbval
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
uv pip install pytest
uv add pytest-ruff nbval
- name: Test Selected Python Scripts
run: |
source .venv/bin/activate
pytest setup/02_installing-python-libraries/tests.py
pytest ch04/01_main-chapter-code/tests.py
pytest ch05/01_main-chapter-code/tests.py
pytest ch05/07_gpt_to_llama/tests/tests.py
pytest ch06/01_main-chapter-code/tests.py
pytest --ruff setup/02_installing-python-libraries/tests.py
pytest --ruff ch04/01_main-chapter-code/tests.py
pytest --ruff ch05/01_main-chapter-code/tests.py
pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
pytest --ruff ch06/01_main-chapter-code/tests.py
- name: Validate Selected Jupyter Notebooks
run: |
source .venv/bin/activate
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
29 changes: 13 additions & 16 deletions .github/workflows/basic-tests-old-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,25 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install pytest nbval
uv pip install torch==${{ matrix.pytorch-version }}
uv pip install -r requirements.txt
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
uv pip install pytest
uv add torch==${{ matrix.pytorch-version }}
uv add pytest-ruff nbval
- name: Test Selected Python Scripts
run: |
source .venv/bin/activate
pytest setup/02_installing-python-libraries/tests.py
pytest ch04/01_main-chapter-code/tests.py
pytest ch05/01_main-chapter-code/tests.py
pytest ch05/07_gpt_to_llama/tests/tests.py
pytest ch06/01_main-chapter-code/tests.py
pytest --ruff setup/02_installing-python-libraries/tests.py
pytest --ruff ch04/01_main-chapter-code/tests.py
pytest --ruff ch05/01_main-chapter-code/tests.py
pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
pytest --ruff ch06/01_main-chapter-code/tests.py
- name: Validate Selected Jupyter Notebooks
run: |
source .venv/bin/activate
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
27 changes: 12 additions & 15 deletions .github/workflows/basic-tests-pytorch-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,25 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install pytest nbval
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
uv add pytest-ruff nbval
uv pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
uv pip install pytest
- name: Test Selected Python Scripts
run: |
source .venv/bin/activate
pytest setup/02_installing-python-libraries/tests.py
pytest ch04/01_main-chapter-code/tests.py
pytest ch05/01_main-chapter-code/tests.py
pytest ch05/07_gpt_to_llama/tests/tests.py
pytest ch06/01_main-chapter-code/tests.py
pytest --ruff setup/02_installing-python-libraries/tests.py
pytest --ruff ch04/01_main-chapter-code/tests.py
pytest --ruff ch05/01_main-chapter-code/tests.py
pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
pytest --ruff ch06/01_main-chapter-code/tests.py
- name: Validate Selected Jupyter Notebooks
run: |
source .venv/bin/activate
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
57 changes: 57 additions & 0 deletions .github/workflows/basic-tests-windows-pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Code tests (Windows pip)

on:
push:
branches: [ main ]
paths:
- '**/*.py'
- '**/*.ipynb'
- '**/*.yaml'
- '**/*.yml'
- '**/*.sh'
pull_request:
branches: [ main ]
paths:
- '**/*.py'
- '**/*.ipynb'
- '**/*.yaml'
- '**/*.yml'
- '**/*.sh'

jobs:
test:
runs-on: windows-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
shell: pwsh
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install tensorflow-io-gcs-filesystem==0.31.0 # Explicit for Windows
pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
pip install pytest-ruff nbval
- name: Run Python Tests
shell: pwsh
run: |
pytest --ruff setup/02_installing-python-libraries/tests.py
pytest --ruff ch04/01_main-chapter-code/tests.py
pytest --ruff ch05/01_main-chapter-code/tests.py
pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
pytest --ruff ch06/01_main-chapter-code/tests.py
- name: Run Jupyter Notebook Tests
shell: pwsh
run: |
pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
57 changes: 57 additions & 0 deletions .github/workflows/basic-tests-windows-uv.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Code tests (Windows)

on:
push:
branches: [ main ]
paths:
- '**/*.py'
- '**/*.ipynb'
- '**/*.yaml'
- '**/*.yml'
- '**/*.sh'
pull_request:
branches: [ main ]
paths:
- '**/*.py'
- '**/*.ipynb'
- '**/*.yaml'
- '**/*.yml'
- '**/*.sh'

jobs:
test:
runs-on: windows-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install uv
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1" -OutFile "uv_install.ps1"
& .\uv_install.ps1

- name: Install dependencies with uv
shell: pwsh
run: |
uv venv --python=python3.10
uv pip install tensorflow-io-gcs-filesystem==0.31.0 # Explicit for Windows
uv pip install -r requirements.txt
uv pip install pytest-ruff

- name: Run Python Tests
shell: pwsh
run: |
uv run pytest --ruff setup/02_installing-python-libraries/tests.py
uv run pytest --ruff ch04/01_main-chapter-code/tests.py
uv run pytest --ruff ch05/01_main-chapter-code/tests.py
uv run pytest --ruff ch05/07_gpt_to_llama/tests/tests.py
uv run pytest --ruff ch06/01_main-chapter-code/tests.py

- name: Run Jupyter Notebook Tests
shell: pwsh
run: |
uv run pytest --ruff --nbval ch02/01_main-chapter-code/dataloader.ipynb
uv run pytest --ruff --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
uv run pytest --ruff --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
57 changes: 0 additions & 57 deletions .github/workflows/basic-tests-windows.yml

This file was deleted.

12 changes: 5 additions & 7 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install pytest pytest-check-links
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv add pytest-ruff pytest-check-links
# Current version of retry doesn't work well if there are broken non-URL links
# pip install pytest pytest-check-links pytest-retry
uv pip install pytest pytest-check-links
- name: Check links
run: |
source .venv/bin/activate
pytest --check-links ./ --check-links-ignore "https://platform.openai.com/*" --check-links-ignore "https://openai.com/*" --check-links-ignore "https://arena.lmsys.org" --check-links-ignore https://unsloth.ai/blog/gradient --check-links-ignore "https://www.reddit.com/r/*" --check-links-ignore "https://code.visualstudio.com/*" --check-links-ignore https://arxiv.org/* --check-links-ignore "https://ai.stanford.edu/~amaas/data/sentiment/"
pytest --ruff --check-links ./ --check-links-ignore "https://platform.openai.com/*" --check-links-ignore "https://openai.com/*" --check-links-ignore "https://arena.lmsys.org" --check-links-ignore https://unsloth.ai/blog/gradient --check-links-ignore "https://www.reddit.com/r/*" --check-links-ignore "https://code.visualstudio.com/*" --check-links-ignore https://arxiv.org/* --check-links-ignore "https://ai.stanford.edu/~amaas/data/sentiment/"
# pytest --check-links ./ --check-links-ignore "https://platform.openai.com/*" --check-links-ignore "https://arena.lmsys.org" --retries 2 --retry-delay 5
9 changes: 4 additions & 5 deletions .github/workflows/check-spelling-errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ jobs:

- name: Install codespell
run: |
python -m pip install --upgrade pip
pip install uv
uv venv --python=python3.10
source .venv/bin/activate
uv pip install codespell
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.10
uv add . --dev
uv add codespell
- name: Run codespell
run: |
Expand Down
Loading

0 comments on commit a08d7aa

Please sign in to comment.