pandas-checks workflow (business-science/pytimetk)
The pandas-checks workflow from business-science/pytimetk, explained and optimized by Latchkey.
CI health: D - needs work
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 pandas-checks workflow from the business-science/pytimetk 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: pandas-checks
on:
schedule:
- cron: '0 0 1 * *'
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
# - { os: ubuntu-latest, python-version: '3.9', pandas-version: '1.5.0' }
- { os: ubuntu-latest, python-version: '3.9', pandas-version: '2.2.0' }
- { os: ubuntu-latest, python-version: '3.11', pandas-version: 'latest' }
defaults:
run:
shell: bash
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.python-version }}) - pandas ${{ matrix.config.pandas-version }}
steps:
- name: Set up Python Version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python-version }}
- name: Check-out repository
uses: actions/checkout@v4
- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry==2.0.1
- name: Install package
run: |
poetry install
if [ "${{ matrix.config.pandas-version }}" == "latest" ]; then
# The lockfile pins pandas-2-era transitive deps; pandas 3 needs newer tsfeatures deps.
poetry run python -m pip install --upgrade "pandas" "arch>=8.0.0" "statsmodels>=0.14.6"
else
poetry run python -m pip install --upgrade "pandas==${{ matrix.config.pandas-version }}"
fi
- run: poetry run pytest --version
- name: Test with pytest
run: poetry run pytest tests/ --verbose
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: pandas-checks on: schedule: - cron: '0 0 1 * *' push: branches: - main - master pull_request: branches: - main - master concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 strategy: fail-fast: false matrix: config: # - { os: ubuntu-latest, python-version: '3.9', pandas-version: '1.5.0' } - { os: ubuntu-latest, python-version: '3.9', pandas-version: '2.2.0' } - { os: ubuntu-latest, python-version: '3.11', pandas-version: 'latest' } defaults: run: shell: bash runs-on: ${{ matrix.config.os }} name: ${{ matrix.config.os }} (${{ matrix.config.python-version }}) - pandas ${{ matrix.config.pandas-version }} steps: - name: Set up Python Version uses: actions/setup-python@v5 with: cache: 'pip' python-version: ${{ matrix.config.python-version }} - name: Check-out repository uses: actions/checkout@v4 - name: Install poetry run: | python -m pip install --upgrade pip python -m pip install poetry==2.0.1 - name: Install package run: | poetry install if [ "${{ matrix.config.pandas-version }}" == "latest" ]; then # The lockfile pins pandas-2-era transitive deps; pandas 3 needs newer tsfeatures deps. poetry run python -m pip install --upgrade "pandas" "arch>=8.0.0" "statsmodels>=0.14.6" else poetry run python -m pip install --upgrade "pandas==${{ matrix.config.pandas-version }}" fi - run: poetry run pytest --version - name: Test with pytest run: poetry run pytest tests/ --verbose
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- 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 1 job (2 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.