Skip to content

Commit 88fd849

Browse files
authored
Switch from pip to uv (rasbt#529)
* Replace pip by more modern uv * uv tests * update yaml * update yaml * update yaml * update flake8 * update windows commands * fix windows test * windows fix * windows fix * windows fix * windows fix * windows fix * windows fix * windows fix * windows fix * windows fix * windows fix
1 parent 074a6ef commit 88fd849

File tree

10 files changed

+250
-38
lines changed

10 files changed

+250
-38
lines changed

.github/workflows/basic-tests-linux.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install pytest nbval
37-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
38-
pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
36+
pip install uv
37+
uv venv --python=python3.10
38+
source .venv/bin/activate
39+
uv pip install pytest nbval
40+
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
41+
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
42+
uv pip install pytest
3943
4044
- name: Test Selected Python Scripts
4145
run: |
46+
source .venv/bin/activate
4247
pytest setup/02_installing-python-libraries/tests.py
4348
pytest ch04/01_main-chapter-code/tests.py
4449
pytest ch05/01_main-chapter-code/tests.py
@@ -47,6 +52,7 @@ jobs:
4752
4853
- name: Validate Selected Jupyter Notebooks
4954
run: |
55+
source .venv/bin/activate
5056
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
5157
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
5258
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb

.github/workflows/basic-tests-macos.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ jobs:
3333
- name: Install dependencies
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install pytest nbval
37-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
38-
pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
36+
pip install uv
37+
uv venv --python=python3.10
38+
source .venv/bin/activate
39+
uv pip install pytest nbval
40+
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
41+
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
42+
uv pip install pytest
3943
4044
- name: Test Selected Python Scripts
4145
run: |
46+
source .venv/bin/activate
4247
pytest setup/02_installing-python-libraries/tests.py
4348
pytest ch04/01_main-chapter-code/tests.py
4449
pytest ch05/01_main-chapter-code/tests.py
@@ -47,6 +52,7 @@ jobs:
4752
4853
- name: Validate Selected Jupyter Notebooks
4954
run: |
55+
source .venv/bin/activate
5056
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
5157
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
5258
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb

.github/workflows/basic-tests-old-pytorch.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ jobs:
3636
- name: Install dependencies
3737
run: |
3838
python -m pip install --upgrade pip setuptools wheel
39-
pip install pytest nbval
40-
pip install torch==${{ matrix.pytorch-version }}
41-
pip install -r requirements.txt
42-
pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
39+
pip install uv
40+
uv venv --python=python3.10
41+
source .venv/bin/activate
42+
uv pip install pytest nbval
43+
uv pip install torch==${{ matrix.pytorch-version }}
44+
uv pip install -r requirements.txt
45+
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
46+
uv pip install pytest
4347
4448
- name: Test Selected Python Scripts
4549
run: |
50+
source .venv/bin/activate
4651
pytest setup/02_installing-python-libraries/tests.py
4752
pytest ch04/01_main-chapter-code/tests.py
4853
pytest ch05/01_main-chapter-code/tests.py
@@ -51,6 +56,7 @@ jobs:
5156
5257
- name: Validate Selected Jupyter Notebooks
5358
run: |
59+
source .venv/bin/activate
5460
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
5561
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
5662
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb

.github/workflows/basic-tests-pytorch-rc.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35-
pip install pytest nbval
36-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
37-
pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
38-
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
35+
pip install uv
36+
uv venv --python=python3.10
37+
source .venv/bin/activate
38+
uv pip install pytest nbval
39+
if [ -f requirements.txt ]; then uv pip install -r requirements.txt; fi
40+
uv pip install -r ch05/07_gpt_to_llama/tests/test-requirements-extra.txt
41+
uv pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
42+
uv pip install pytest
3943
4044
- name: Test Selected Python Scripts
4145
run: |
46+
source .venv/bin/activate
4247
pytest setup/02_installing-python-libraries/tests.py
4348
pytest ch04/01_main-chapter-code/tests.py
4449
pytest ch05/01_main-chapter-code/tests.py
@@ -47,6 +52,7 @@ jobs:
4752
4853
- name: Validate Selected Jupyter Notebooks
4954
run: |
55+
source .venv/bin/activate
5056
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
5157
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
5258
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb

.github/workflows/basic-tests-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ jobs:
5454
run: |
5555
pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb
5656
pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb
57-
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb
57+
pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb

.github/workflows/check-links.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install pytest pytest-check-links
26+
pip install uv
27+
uv venv --python=python3.10
28+
source .venv/bin/activate
29+
uv pip install pytest pytest-check-links
2730
# Current version of retry doesn't work well if there are broken non-URL links
2831
# pip install pytest pytest-check-links pytest-retry
32+
uv pip install pytest pytest-check-links
2933
3034
- name: Check links
3135
run: |
36+
source .venv/bin/activate
3237
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/"
3338
# pytest --check-links ./ --check-links-ignore "https://platform.openai.com/*" --check-links-ignore "https://arena.lmsys.org" --retries 2 --retry-delay 5
3439

.github/workflows/check-spelling-errors.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ jobs:
2323
- name: Install codespell
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install codespell
26+
pip install uv
27+
uv venv --python=python3.10
28+
source .venv/bin/activate
29+
uv pip install codespell
2730
2831
- name: Run codespell
2932
run: |
33+
source .venv/bin/activate
3034
codespell -L "ocassion,occassion,ot,te,tje" **/*.{txt,md,py,ipynb}

.github/workflows/pep8-linter.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jobs:
1616
with:
1717
python-version: '3.10'
1818
- name: Install flake8
19-
run: pip install flake8
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install uv
22+
uv venv --python=python3.10
23+
source .venv/bin/activate
24+
uv pip install flake8
25+
2026
- name: Run flake8 with exceptions
21-
run: flake8 . --max-line-length=140 --ignore=W504,E402,E731,C406,E741,E722,E226
27+
run: |
28+
source .venv/bin/activate
29+
flake8 . --max-line-length=140 --ignore=W504,E402,E731,C406,E741,E722,E226 --exclude .venv

0 commit comments

Comments
 (0)