Skip to content

Upgrade requirements.txt #6

Upgrade requirements.txt

Upgrade requirements.txt #6

# This GitHub Actions workflow must be manually triggered and
# upgrades pinned transitive dependencies in requirements.txt
# to their latest versions.
name: Upgrade requirements.txt
on: workflow_dispatch
jobs:
upgrade-requirements:
name: Upgrade requirements.txt
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install PyTorch manually
# PyTorch has to be installed manually in a separate step with --no-cache-dir
# to avoid pip getting killed because PyTorch is too big
# See: https://stackoverflow.com/a/54329850
run: pip install torch==2.2.2 torchvision==0.17.2 --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
- name: Upgrade dependencies
run: pip install --upgrade --upgrade-strategy eager -e .[all,dev] torch==2.2.2 torchvision==0.17.2
- name: Verify dependencies
run: pip check
- name: Write header to requirements.txt
run: echo '# This file is automatically generated by GitHub Actions and contains pinned versions for all transitive Python dependencies. Do not modify this file!' > requirements.txt
- name: Write dependencies to requirements.txt
# grep is used to exclude dependencies installed in editable mode
# and dependencies installed from outside PyPI.
# sed is used to loosen the version matches for PyTorch
# so that any CUDA version matches.
run: pip freeze | grep -v -E "( @ |^-e)" | sed -E 's/==([A-Za-z0-9.]+)\+[A-Za-z0-9.]+/~=\1/' >> requirements.txt
# Need to manually run tests here because the pull request opened later will not
# run the test workflow.
#
# From https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
#
# ...events triggered by the GITHUB_TOKEN... will not create a new workflow run.
# This prevents you from accidentally creating recursive workflow runs. For example,
# if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow
# will not run even when the repository contains a workflow configured to run when
# push events occur.
- name: Run linter
run: ./pre-commit.sh
- name: Run tests
run: pytest
- name: Run helm-run
run: helm-run --suite test --run-entries simple1:model=simple/model1 --max-eval-instances 10 --exit-on-error
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Upgrade requirements.txt
title: "Upgrade requirements.txt"
branch: actions/upgrade-requirements
delete-branch: true
body: Auto-generated from GitHub Actions.