Skip to content
Latchkey

compatibility test for Numpy and TensorFlow 1 workflow (massquantity/LibRecommender)

The compatibility test for Numpy and TensorFlow 1 workflow from massquantity/LibRecommender, explained and optimized by Latchkey.

C

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 →
Source: massquantity/LibRecommender.github/workflows/compatibility-tensorflow1.ymlLicense MITView source

What it does

This is the compatibility test for Numpy and TensorFlow 1 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

workflow (.yml)
name: compatibility test for Numpy and TensorFlow 1

on:
  # Manual run
  workflow_dispatch:

jobs:
  build:
    name: nt1
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, windows-latest, macos-latest]
        python-version: [3.7]
        tensorflow-version: [1.15.0, 1.15.5]
        numpy-version: [1.20.3, 1.21.6]
        include:
          # Python 3.6 only supports Numpy 1.19.5
          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5

          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5

          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5

          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5

    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: Install dataclasses
        run: |
          python -m pip install dataclasses
        if: matrix.python-version == '3.6'

      - 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 1
 
on:
  # Manual run
  workflow_dispatch:
 
jobs:
  build:
    timeout-minutes: 30
    name: nt1
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04, windows-latest, macos-latest]
        python-version: [3.7]
        tensorflow-version: [1.15.0, 1.15.5]
        numpy-version: [1.20.3, 1.21.6]
        include:
          # Python 3.6 only supports Numpy 1.19.5
          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
 
          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.14.0
            numpy-version: 1.19.5
 
          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.0
            numpy-version: 1.19.5
 
          - os: ubuntu-20.04
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5
          - os: windows-latest
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5
          - os: macos-latest
            python-version: '3.6'
            tensorflow-version: 1.15.5
            numpy-version: 1.19.5
 
    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: Install dataclasses
        run: |
          python -m pip install dataclasses
        if: matrix.python-version == '3.6'
 
      - 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

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:

This workflow runs 1 job (12 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow