Merge pull request #166 from kartelj/master #350
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
# Controls when the action will run. | |
on: | |
push: | |
paths: | |
- 'algorithms/**' | |
- 'experiment/**' | |
- '.github/workflows/**' | |
pull_request: | |
paths: | |
- 'algorithms/**' | |
- 'experiment/**' | |
- '.github/workflows/**' | |
workflow_dispatch: | |
env: | |
CACHE_NUMBER: 0 | |
jobs: | |
################################################################################ | |
# matrix build and test | |
################################################################################ | |
base-env-build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v3 | |
- | |
name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: srbench | |
use-mamba: true | |
- | |
name: Cache srbench environment | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
id: cache | |
- | |
name: Update srbench environment | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
echo "Didn't find the cache for the srbench environment :(" | |
conda info --envs | |
mamba env update -n srbench -f environment.yml | |
list-algs: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v2 | |
- id: set-matrix | |
run: echo "::set-output name=matrix::$(ls algorithms/ | jq -R -s -c 'split("\n")[:-1]')" | |
build-and-test: | |
runs-on: ubuntu-latest | |
needs: | |
- base-env-build | |
- list-algs | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
matrix: | |
# folder: ${{ fromJSON(needs.detect-directory-changes.outputs.changed) }} | |
alg: ${{ fromJson(needs.list-algs.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- | |
name: Checkout code | |
uses: actions/checkout@v3 | |
- | |
name: Filter to changed paths | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
alg: | |
- format('algorithms/{0}/**', matrix.alg) | |
- | |
name: Setup Mambaforge | |
# if: steps.changes.outputs.alg == 'true' | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: srbench | |
use-mamba: true | |
- | |
name: Cache srbench environment | |
id: cache-srbench | |
# if: steps.changes.outputs.alg == 'true' | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
restore-keys: | | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
- | |
name: Update srbench environment | |
if: steps.cache-srbench.outputs.cache-hit != 'true' | |
run: | | |
echo "Didn't find the cache for the srbench environment :(" | |
conda info --envs | |
mamba env update -n srbench -f environment.yml | |
################################################################################ | |
# install the submission | |
################################################################################ | |
- | |
name: Cache alg environment | |
id: cache-alg | |
# if: steps.changes.outputs.alg == 'true' | |
uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/srbench-${{ matrix.alg }} | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles(format('./algorithms/{0}/**', matrix.alg)) }} | |
- | |
name: Create alg environment | |
if: steps.cache-alg.outputs.cache-hit != 'true' | |
run: | | |
echo "Installing dependencies for ${{ matrix.alg }}" | |
echo "Copying base environment" | |
conda create --name srbench-${{ matrix.alg }} --clone srbench | |
- | |
name: Update alg env from environment.yml | |
if: | | |
steps.cache-alg.outputs.cache-hit != 'true' | |
&& hashFiles(format('./algorithms/{0}/environment.yml', matrix.alg)) != '' | |
run: | | |
mamba env update -n srbench-${{ matrix.alg }} -f algorithms/${{ matrix.alg }}/environment.yml | |
- | |
name: Update alg env from requirements.txt | |
if: | | |
steps.cache-alg.outputs.cache-hit != 'true' | |
&& hashFiles(format('./algorithms/{0}/requirements.txt', matrix.alg)) != '' | |
run: | | |
mamba run -n srbench-${{ matrix.alg }} pip install -r algorithms/${{ matrix.alg }}/requirements.txt | |
- | |
name: Run install.sh | |
if: | | |
steps.cache-alg.outputs.cache-hit != 'true' | |
&& hashFiles(format('./algorithms/{0}/install.sh', matrix.alg)) != '' | |
run: | | |
cd algorithms/${{ matrix.alg }} | |
echo "running install.sh..." | |
mamba run -n srbench-${{ matrix.alg }} bash install.sh | |
- | |
name: Copy files and environment | |
# if: steps.changes.outputs.alg == 'true' | |
run: | | |
mkdir -p experiment/methods/${{ matrix.alg }} | |
cp algorithms/${{ matrix.alg }}/regressor.py experiment/methods/${{ matrix.alg }}/ | |
cp algorithms/${{ matrix.alg }}/metadata.yml experiment/methods/${{ matrix.alg }}/ | |
touch experiment/methods/${{ matrix.alg }}/__init__.py | |
# export env | |
eval "$(conda shell.bash hook)" | |
conda init bash | |
conda activate $subenv | |
echo "/////// Conda Environment (conda env export)/////" | |
conda env export #> algorithms/${{ matrix.alg }}/environment.lock.yml | |
echo "/////////////////////////////////////////////////" | |
################################################################################ | |
# tests | |
################################################################################ | |
- | |
name: Test Method | |
run: | | |
cd experiment | |
pwd | |
ls | |
mamba run -n srbench-${{ matrix.alg }} python -m pytest -v test_algorithm.py --ml ${{ matrix.alg }} | |
################################################################################ |