Skip to content

install from main instead of release (#24) #88

install from main instead of release (#24)

install from main instead of release (#24) #88

name: Runs and Deploy
on:
push:
branches:
- main
tags:
- '**'
workflow_dispatch:
inputs:
benchmark_dir:
description: 'Single benchmark dir to run (leave empty to run all)'
required: false
default: ''
jobs:
find-benchmarks:
runs-on: ubuntu-latest
outputs:
benchmark-dirs: ${{ steps.find-dirs.outputs.dirs }}
found_benchmarks: ${{ steps.find-dirs.outputs.found_benchmarks }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install dependencies
run: pip install GitPython
- name: Find benchmark directories
id: find-dirs
run: python .github/scripts/find_benchmarks.py
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}
DISPATCH_BENCHMARK_DIR: ${{ inputs.benchmark_dir }}
run-benchmarks:
runs-on: gpu # ubuntu-latest
needs: find-benchmarks
if : needs.find-benchmarks.outputs.found_benchmarks == 'True'
timeout-minutes: 4320 # 3 days (max)
strategy:
matrix:
benchmark_dir: ${{ fromJson(needs.find-benchmarks.outputs.benchmark-dirs) }}
exclude:
# don't run on the template benchmark, which is not meant to be run
- benchmark_dir: "deepinv_bench/benchmarks/benchmark_template"
env:
HOME: /local/jtachell/runner-${{ matrix.benchmark_dir }}
RUNNER_TEMP: /local/jtachell/runner-${{ matrix.benchmark_dir }}/temp
# BASH_ENV is sourced by non-login bash shells - $HOME expanded by bash
BASH_ENV: $HOME/.profile
# Setup conda and benchopt
RUN_CONDA_ENV: 'deepinv_bench'
BENCHOPT_CONDA_CMD: 'mamba'
BENCHOPT_RAISE_INSTALL_ERROR: true
BENCHOPT_DEBUG: 1
defaults:
run:
# Use non-login shell with BASH_ENV instead of -l to ensure
# $HOME/.profile is sourced
shell: bash -eo pipefail {0}
steps:
- uses: actions/checkout@v6
- name: Setup runner isolation
shell: bash
run: |
rm -rf $HOME || echo "HOME "$HOME" doesn't exist"
mkdir -p $HOME
- name: Compute cache key based on the date (monthly)
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
shell: bash
- name: Cache benchopt runs and conda packages
id: cache-benchopt
uses: actions/cache/restore@v5 # restore only
with:
path: |
${{ matrix.benchmark_dir }}/__cache__
key: ${{ runner.os }}-${{matrix.benchmark_dir}}-${{ steps.get-date.outputs.date }}
- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
miniforge-version: latest
mamba-version: "*"
use-mamba: true
channels: conda-forge
conda-remove-defaults: true
python-version: '3.11'
activate-environment: ${{ env.RUN_CONDA_ENV }}
- name: Install benchopt and its dependencies
run: |
mamba install -yq pip
pip install -U git+https://github.com/benchopt/benchopt huggingface_hub
- name: Install benchmark dependencies
run: |
benchopt install -y ${{ matrix.benchmark_dir }} \
--env-name ${{ env.RUN_CONDA_ENV }}
- name: Run benchmarks
run: |
benchopt run ${{ matrix.benchmark_dir }} --output results_ci_run.csv \
--no-plot --env-name ${{ env.RUN_CONDA_ENV }}
- name: Upload results
if: always()
run: |
benchopt publish ${{ matrix.benchmark_dir }} --hub huggingface \
--filename ${{ matrix.benchmark_dir }}/outputs/results_ci_run.csv \
--repo deepinv/benchmarks --keep last \
--token ${{ secrets.HF_TOKEN }}
- name: Save cache
if: always()
uses: actions/cache/save@v5
with:
path: |
${{ matrix.benchmark_dir }}/__cache__
key: ${{ runner.os }}-${{matrix.benchmark_dir}}-${{ steps.get-date.outputs.date }}