From 5ae5e9df3b9a95646e01bf45873fee70a53e5279 Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sun, 28 Apr 2024 07:39:23 -0500 Subject: [PATCH] Try windows runners (#133) * try windows runners * update triggers * trigger with code file update * add new status badges --- ...{basic-tests.yml => basic-tests-linux.yml} | 10 ++-- .github/workflows/basic-tests-macos.yml | 47 +++++++++++++++++ .github/workflows/basic-tests-windows.yml | 51 +++++++++++++++++++ README.md | 4 +- .../ch03.py | 8 +++ 5 files changed, 116 insertions(+), 4 deletions(-) rename .github/workflows/{basic-tests.yml => basic-tests-linux.yml} (84%) create mode 100644 .github/workflows/basic-tests-macos.yml create mode 100644 .github/workflows/basic-tests-windows.yml diff --git a/.github/workflows/basic-tests.yml b/.github/workflows/basic-tests-linux.yml similarity index 84% rename from .github/workflows/basic-tests.yml rename to .github/workflows/basic-tests-linux.yml index 2da136d..5a17259 100644 --- a/.github/workflows/basic-tests.yml +++ b/.github/workflows/basic-tests-linux.yml @@ -1,16 +1,20 @@ -name: Code tests +name: Code tests on Linux on: push: branches: [ main ] paths: - - '**/*.py' # Run workflow for changes in Python files - - '**/*.ipynb' # Run workflow for changes in Jupyter notebooks + - '**/*.py' # Run workflow for changes in Python files + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.sh' pull_request: branches: [ main ] paths: - '**/*.py' - '**/*.ipynb' + - '**/*.yaml' + - '**/*.sh' jobs: test: diff --git a/.github/workflows/basic-tests-macos.yml b/.github/workflows/basic-tests-macos.yml new file mode 100644 index 0000000..23e695e --- /dev/null +++ b/.github/workflows/basic-tests-macos.yml @@ -0,0 +1,47 @@ +name: Code tests on macOS + +on: + push: + branches: [ main ] + paths: + - '**/*.py' # Run workflow for changes in Python files + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.sh' + pull_request: + branches: [ main ] + paths: + - '**/*.py' + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.sh' + +jobs: + test: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest nbval + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Test Selected Python Scripts + run: | + pytest ch04/01_main-chapter-code/tests.py + pytest ch05/01_main-chapter-code/tests.py + pytest setup/02_installing-python-libraries/tests.py + + - name: Validate Selected Jupyter Notebooks + run: | + 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 diff --git a/.github/workflows/basic-tests-windows.yml b/.github/workflows/basic-tests-windows.yml new file mode 100644 index 0000000..eeb9d79 --- /dev/null +++ b/.github/workflows/basic-tests-windows.yml @@ -0,0 +1,51 @@ +name: Code tests on Windows + +on: + push: + branches: [ main ] + paths: + - '**/*.py' # Run workflow for changes in Python files + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.sh' + pull_request: + branches: [ main ] + paths: + - '**/*.py' + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.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: bash + run: | + python -m pip install --upgrade pip + pip install pytest nbval + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Test Selected Python Scripts + shell: bash + run: | + pytest ch04/01_main-chapter-code/tests.py + pytest ch05/01_main-chapter-code/tests.py + pytest setup/02_installing-python-libraries/tests.py + + - name: Validate Selected Jupyter Notebooks + shell: bash + run: | + 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 diff --git a/README.md b/README.md index bfeec20..de78e26 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,10 @@ Alternatively, you can view this and other files on GitHub at [https://github.co
+[![Code tests on Linux](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-linux.yml/badge.svg)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-linux.yml) +[![Code tests on Windows](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-windows.yml/badge.svg?123)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-windows.yml) +[![Code tests on macOS](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-macos.yml/badge.svg)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests-macos.yml) [![Python PEP8 linting](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/pep8-linter.yml/badge.svg)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/pep8-linter.yml) -[![Python tests](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests.yml/badge.svg)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/basic-tests.yml) [![Check hyperlinks](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/check-links.yml/badge.svg)](https://github.com/rasbt/LLMs-from-scratch/actions/workflows/check-links.yml)
diff --git a/ch03/02_bonus_efficient-multihead-attention/ch03.py b/ch03/02_bonus_efficient-multihead-attention/ch03.py index 0ee3ca9..b6cb9ec 100644 --- a/ch03/02_bonus_efficient-multihead-attention/ch03.py +++ b/ch03/02_bonus_efficient-multihead-attention/ch03.py @@ -1,3 +1,11 @@ +# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt). +# Source for "Build a Large Language Model From Scratch" +# - https://www.manning.com/books/build-a-large-language-model-from-scratch +# Code: https://github.com/rasbt/LLMs-from-scratch +# +# This file contains the relevant code from chapter 3 that is going to be used +# in forthcoming chapters. + import torch import torch.nn as nn