Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for python 3.9 to 3.12 #124

Merged
merged 9 commits into from
May 15, 2024
74 changes: 56 additions & 18 deletions .github/workflows/simulation_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,40 @@ on:
description: 'libsonata branch to use'
required: false


env:
NEURON_COMMIT_ID: '13654b3'
NEURON_BRANCH: ${{ inputs.LIBSONATA_REPORT_BRANCH || 'master' }}
NEURON_BRANCH: ${{ inputs.NEURON_BRANCH || 'master' }}
LIBSONATA_REPORT_BRANCH: ${{ inputs.LIBSONATA_REPORT_BRANCH || '1.2.3' }}
LIBSONATA_BRANCH: ${{ inputs.LIBSONATA_BRANCH || 'v0.1.26' }}

jobs:
simulation:
runs-on: ubuntu-22.04
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Checkout neurodamus repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.os }}-pip-${{ matrix.python-version }}-v1
restore-keys: |
${{ matrix.os }}-pip-

- name: Get HEAD commit message and look for branches
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
Expand All @@ -44,11 +60,13 @@ jobs:
if [[ ! -z $NEURON_BRANCH ]]; then echo "NEURON_BRANCH=$NEURON_BRANCH" >> $GITHUB_ENV; fi
LIBSONATA_REPORT_BRANCH=$(echo $COMMIT_MESSAGE | grep -Po 'LIBSONATA_REPORT_BRANCH=\K[0-9a-zA-Z/_.\-]*' || true)
if [[ ! -z $LIBSONATA_REPORT_BRANCH ]]; then echo "LIBSONATA_REPORT_BRANCH=$LIBSONATA_REPORT_BRANCH" >> $GITHUB_ENV; fi
LIBSONATA_BRANCH=$(echo $COMMIT_MESSAGE | grep -Po 'LIBSONATA_BRANCH=\K[0-9a-zA-Z/_.\-]*' || true)
if [[ ! -z $LIBSONATA_BRANCH ]]; then echo "LIBSONATA_BRANCH=$LIBSONATA_BRANCH" >> $GITHUB_ENV; fi

- name: Install hdf5-mpich
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install mpich libmpich-dev libhdf5-mpich-dev hdf5-tools
sudo apt-get install -y mpich libmpich-dev libhdf5-mpich-dev hdf5-tools flex libfl-dev bison ninja-build

- name: Cache python virtual env
id: cache-venv
Expand All @@ -57,12 +75,19 @@ jobs:
cache-name: cache-venv
with:
path: venv
key: build-libsonata-${{ env.LIBSONATA_BRANCH }} # todo: add python version
key: ${{ matrix.os }}-libsonata-${{ env.LIBSONATA_BRANCH }}-py${{ matrix.python-version }}

- name: Install libsonata
- name: Upgrade pip and install base Python packages
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. ./venv/bin/activate
python -m pip install --upgrade pip setuptools
pip install cython numpy wheel pkgconfig

- name: Install libsonata
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
. ./venv/bin/activate
CC=mpicc CXX=mpic++ pip install git+https://github.com/BlueBrain/libsonata

Expand All @@ -73,7 +98,7 @@ jobs:
cache-name: cache-libsonatareport
with:
path: libsonatareport
key: build-libsonatareport-${{ env.LIBSONATA_REPORT_BRANCH }}
key: ${{ matrix.os }}-libsonatareport-${{ env.LIBSONATA_REPORT_BRANCH }}-py${{ matrix.python-version }}

- name: Install libsonatareport
if: steps.cache-libsonatareport.outputs.cache-hit != 'true'
Expand All @@ -92,25 +117,35 @@ jobs:
cache-name: cache-neuron
with:
path: nrn
key: build-neuron-${{ env.NEURON_BRANCH }}-${{ env.NEURON_COMMIT_ID }}
key: ${{ matrix.os }}-neuron-${{ env.NEURON_BRANCH }}-${{ env.NEURON_COMMIT_ID }}-py${{ matrix.python-version }}

- name: Install NEURON
if: steps.cache-neuron.outputs.cache-hit != 'true'
run: |
export SONATAREPORT_DIR=$(pwd)/libsonatareport/build/install
sudo apt-get install flex libfl-dev bison ninja-build
. ./venv/bin/activate
git clone --branch=${{ env.NEURON_BRANCH }} https://github.com/neuronsimulator/nrn.git
cd nrn
if [[ ${{ env.NEURON_BRANCH }} == 'master' ]]; then
git clone --branch=${{ env.NEURON_BRANCH }} https://github.com/neuronsimulator/nrn.git
cd nrn
git checkout ${{ env.NEURON_COMMIT_ID }}
cd ..
else
git clone --branch=${{ env.NEURON_BRANCH }} https://github.com/neuronsimulator/nrn.git --depth=1
fi
python -m pip install --upgrade pip -r nrn_requirements.txt
mkdir build && cd build
cmake -G Ninja -DPYTHON_EXECUTABLE=$(which python) -DCMAKE_INSTALL_PREFIX=$(pwd)/install -DNRN_ENABLE_MPI=ON -DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_CORENEURON=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCORENRN_ENABLE_REPORTING=ON -DCMAKE_PREFIX_PATH=$SONATAREPORT_DIR ..
cmake --build . --parallel
cmake --build . --target install
. ./venv/bin/activate
python -m pip install --upgrade pip -r nrn/nrn_requirements.txt
cmake -B nrn/build -S nrn -G Ninja \
-DPYTHON_EXECUTABLE=$(which python) \
-DCMAKE_INSTALL_PREFIX=$(pwd)/nrn/build/install \
-DNRN_ENABLE_MPI=ON \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_CORENEURON=ON \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCORENRN_ENABLE_REPORTING=ON \
-DCMAKE_PREFIX_PATH=$SONATAREPORT_DIR
cmake --build nrn/build --parallel
cmake --build nrn/build --target install
jorblancoa marked this conversation as resolved.
Show resolved Hide resolved

- name: Install mpi4py
if: steps.cache-venv.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -144,6 +179,9 @@ jobs:
- name: Example run
run: |
. ./venv/bin/activate
if [ ${{ matrix.python-version }} == 3.9 ]; then
export RDMAV_FORK_SAFE=1
fi;
export PYTHONPATH=$(pwd)/nrn/build/lib/python:$PYTHONPATH
cp neurodamus/data/hoc/* tests/share/hoc/
export HOC_LIBRARY_PATH=$(pwd)/tests/share/hoc
Expand Down
Loading