Skip to content

Commit

Permalink
Refactor CI workflows to standardize matrix variable naming and enhan…
Browse files Browse the repository at this point in the history
…ce caching logic. Added installation steps for PyTorch versions 1.13.1 and 2.5.1, and included a step to display installed packages. This improves clarity and consistency across CI configurations.
  • Loading branch information
fcakyon committed Dec 16, 2024
1 parent 6190eab commit f37232c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.9, "3.10"]
torch-version: [1.13.1, 2.5.1]
fail-fast: false
Expand All @@ -27,23 +27,23 @@ jobs:

- name: Restore Ubuntu cache
uses: actions/cache@v4
if: matrix.operating-system == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest'
with:
path: ~/.cache/pip
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-

- name: Restore MacOS cache
uses: actions/cache@v4
if: matrix.operating-system == 'macos-latest'
if: matrix.os == 'macos-latest'
with:
path: ~/Library/Caches/pip
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-

- name: Restore Windows cache
uses: actions/cache@v4
if: matrix.operating-system == 'windows-latest'
if: matrix.os == 'windows-latest'
with:
path: ~\AppData\Local\pip\Cache
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
Expand All @@ -52,9 +52,14 @@ jobs:
- name: Update pip
run: python -m pip install --upgrade pip

- name: Install package in development mode
run: pip install -e .[dev]

- name: Show installed packages
run: pip list

- name: Lint with flake8, black and isort
run: |
pip install -e .[dev]
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
black . --check --config pyproject.toml
Expand All @@ -66,17 +71,23 @@ jobs:
run: >
pip install numpy
- name: Install PyTorch on Linux and Windows
- name: Install PyTorch==1.13.1 on Linux and Windows
if: >
matrix.operating-system == 'ubuntu-latest' ||
matrix.operating-system == 'windows-latest'
(matrix.os == 'ubuntu-latest' ||
matrix.os == 'windows-latest') &&
matrix.torch-version == '1.13.1'
run: >
pip install torch==${{ matrix.torch-version }}+cpu
-f https://download.pytorch.org/whl/torch_stable.html
- name: Install PyTorch on MacOS
if: matrix.operating-system == 'macos-latest'
run: pip install torch==${{ matrix.torch-version }}
- name: Install PyTorch==2.5.1 on Linux and Windows
if: >
(matrix.os == 'ubuntu-latest' ||
matrix.os == 'windows-latest') &&
matrix.torch-version == '2.5.1'
run: >
pip install torch==${{ matrix.torch-version }}
-f https://download.pytorch.org/whl/torch_stable.html
- name: Install balanced-loss package from local setup.py
run: >
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/package_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.9, "3.10"]
torch-version: [1.13.1, 2.5.1]
fail-fast: false
Expand All @@ -26,23 +26,23 @@ jobs:

- name: Restore Ubuntu cache
uses: actions/cache@v4
if: matrix.operating-system == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest'
with:
path: ~/.cache/pip
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-

- name: Restore MacOS cache
uses: actions/cache@v4
if: matrix.operating-system == 'macos-latest'
if: matrix.os == 'macos-latest'
with:
path: ~/Library/Caches/pip
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-

- name: Restore Windows cache
uses: actions/cache@v4
if: matrix.operating-system == 'windows-latest'
if: matrix.os == 'windows-latest'
with:
path: ~\AppData\Local\pip\Cache
key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/setup.py')}}
Expand All @@ -55,16 +55,26 @@ jobs:
run: >
pip install numpy
- name: Install PyTorch on Linux and Windows
- name: Install PyTorch==1.13.1 on Linux and Windows
if: >
matrix.operating-system == 'ubuntu-latest' ||
matrix.operating-system == 'windows-latest'
(matrix.os == 'ubuntu-latest' ||
matrix.os == 'windows-latest') &&
matrix.torch-version == '1.13.1'
run: >
pip install torch==${{ matrix.torch-version }}+cpu
-f https://download.pytorch.org/whl/torch_stable.html
- name: Install PyTorch==2.5.1 on Linux and Windows
if: >
(matrix.os == 'ubuntu-latest' ||
matrix.os == 'windows-latest') &&
matrix.torch-version == '2.5.1'
run: >
pip install torch==${{ matrix.torch-version }}
-f https://download.pytorch.org/whl/torch_stable.html
- name: Install PyTorch on MacOS
if: matrix.operating-system == 'macos-latest'
if: matrix.os == 'macos-latest'
run: pip install torch==${{ matrix.torch-version }}

- name: Install latest balanced-loss package
Expand All @@ -74,4 +84,3 @@ jobs:
- name: Unittest balanced-loss
run: |
python -m unittest

0 comments on commit f37232c

Please sign in to comment.