compatibility test for Numpy and TensorFlow 2 workflow (massquantity/LibRecommender)
The compatibility test for Numpy and TensorFlow 2 workflow from massquantity/LibRecommender, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the compatibility test for Numpy and TensorFlow 2 workflow from the massquantity/LibRecommender repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: compatibility test for Numpy and TensorFlow 2
on:
# Manual run
workflow_dispatch:
jobs:
py37:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: [3.7]
tensorflow-version: [2.6.5, 2.10.1]
numpy-version: [1.20.3, 1.21.6]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
# exclude TensorFlow in requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install 'protobuf<=3.20.2'
python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ')
python -m pip install LibRecommender
python -m pip install tensorflow==${{ matrix.tensorflow-version }}
python -m pip install numpy==${{ matrix.numpy-version }}
- name: Test wheels compatibility on Linux
run: |
cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/
cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/
python -m compatibility_test
if: matrix.os == 'ubuntu-20.04'
- name: Test wheels compatibility on Windows
run: |
copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\
copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\"
python -m compatibility_test
if: matrix.os == 'windows-latest'
- name: Test wheels compatibility on macOS
run: |
cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/
cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/
python -m compatibility_test
if: matrix.os == 'macos-latest'
py38:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: [3.8, 3.9]
tensorflow-version: [2.6.5, 2.10.1, 2.12.0]
numpy-version: [1.22.4, 1.23.4]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
# exclude TensorFlow in requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install 'protobuf<=3.20.2'
python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ')
python -m pip install LibRecommender
python -m pip install tensorflow==${{ matrix.tensorflow-version }}
python -m pip install numpy==${{ matrix.numpy-version }}
- name: Test wheels compatibility on Linux
run: |
cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/
cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/
python -m compatibility_test
if: matrix.os == 'ubuntu-20.04'
- name: Test wheels compatibility on Windows
run: |
copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\
copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\"
python -m compatibility_test
if: matrix.os == 'windows-latest'
- name: Test wheels compatibility on macOS
run: |
cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/
cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/
python -m compatibility_test
if: matrix.os == 'macos-latest'
py310:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ['3.10']
tensorflow-version: [2.10.1, 2.12.0]
numpy-version: [1.22.4, 1.23.4, 1.24.2]
include:
- os: ubuntu-20.04
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.23.4
- os: windows-latest
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.23.4
- os: macos-latest
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.23.4
- os: ubuntu-20.04
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.24.2
- os: windows-latest
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.24.2
- os: macos-latest
python-version: '3.11'
tensorflow-version: 2.12.0
numpy-version: 1.24.2
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
# exclude TensorFlow in requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install 'protobuf<=3.20.2'
python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ')
python -m pip install LibRecommender
python -m pip install tensorflow==${{ matrix.tensorflow-version }}
python -m pip install numpy==${{ matrix.numpy-version }}
- name: Test wheels compatibility on Linux
run: |
cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/
cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/
python -m compatibility_test
if: matrix.os == 'ubuntu-20.04'
- name: Test wheels compatibility on Windows
run: |
copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\
copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\"
python -m compatibility_test
if: matrix.os == 'windows-latest'
- name: Test wheels compatibility on macOS
run: |
cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/
cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/
python -m compatibility_test
if: matrix.os == 'macos-latest'The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: compatibility test for Numpy and TensorFlow 2 on: # Manual run workflow_dispatch: jobs: py37: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest, macos-latest] python-version: [3.7] tensorflow-version: [2.6.5, 2.10.1] numpy-version: [1.20.3, 1.21.6] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" # exclude TensorFlow in requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip wheel setuptools python -m pip install 'protobuf<=3.20.2' python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ') python -m pip install LibRecommender python -m pip install tensorflow==${{ matrix.tensorflow-version }} python -m pip install numpy==${{ matrix.numpy-version }} - name: Test wheels compatibility on Linux run: | cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/ cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/ python -m compatibility_test if: matrix.os == 'ubuntu-20.04' - name: Test wheels compatibility on Windows run: | copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\ copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\" python -m compatibility_test if: matrix.os == 'windows-latest' - name: Test wheels compatibility on macOS run: | cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/ cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/ python -m compatibility_test if: matrix.os == 'macos-latest' py38: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest, macos-latest] python-version: [3.8, 3.9] tensorflow-version: [2.6.5, 2.10.1, 2.12.0] numpy-version: [1.22.4, 1.23.4] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" # exclude TensorFlow in requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip wheel setuptools python -m pip install 'protobuf<=3.20.2' python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ') python -m pip install LibRecommender python -m pip install tensorflow==${{ matrix.tensorflow-version }} python -m pip install numpy==${{ matrix.numpy-version }} - name: Test wheels compatibility on Linux run: | cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/ cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/ python -m compatibility_test if: matrix.os == 'ubuntu-20.04' - name: Test wheels compatibility on Windows run: | copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\ copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\" python -m compatibility_test if: matrix.os == 'windows-latest' - name: Test wheels compatibility on macOS run: | cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/ cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/ python -m compatibility_test if: matrix.os == 'macos-latest' py310: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-20.04, windows-latest, macos-latest] python-version: ['3.10'] tensorflow-version: [2.10.1, 2.12.0] numpy-version: [1.22.4, 1.23.4, 1.24.2] include: - os: ubuntu-20.04 python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.23.4 - os: windows-latest python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.23.4 - os: macos-latest python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.23.4 - os: ubuntu-20.04 python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.24.2 - os: windows-latest python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.24.2 - os: macos-latest python-version: '3.11' tensorflow-version: 2.12.0 numpy-version: 1.24.2 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" # exclude TensorFlow in requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip wheel setuptools python -m pip install 'protobuf<=3.20.2' python -m pip install $(sed "/tensorflow*/d;/nmslib*/d;/dgl*/d;/dataclasses*/d" requirements.txt | tr -d ' ') python -m pip install LibRecommender python -m pip install tensorflow==${{ matrix.tensorflow-version }} python -m pip install numpy==${{ matrix.numpy-version }} - name: Test wheels compatibility on Linux run: | cp tests/sample_data/sample_movielens_rating.dat /home/runner/work/ cp tests/compatibility_test.py /home/runner/work/ && cd /home/runner/work/ python -m compatibility_test if: matrix.os == 'ubuntu-20.04' - name: Test wheels compatibility on Windows run: | copy D:\a\LibRecommender\LibRecommender\tests\sample_data\sample_movielens_rating.dat D:\a\ copy D:\a\LibRecommender\LibRecommender\tests\compatibility_test.py D:\a\ && Set-Location -Path "D:\a\" python -m compatibility_test if: matrix.os == 'windows-latest' - name: Test wheels compatibility on macOS run: | cp tests/sample_data/sample_movielens_rating.dat /Users/runner/work/ cp tests/compatibility_test.py /Users/runner/work/ && cd /Users/runner/work/ python -m compatibility_test if: matrix.os == 'macos-latest'
What changed
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 3 jobs (66 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.