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

[ENH] add caching action for elephant-data #633

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ccd587a
initial draft for caching action
Moritz-Alexander-Kern Apr 18, 2024
ee366df
add trigger for workflow
Moritz-Alexander-Kern Apr 18, 2024
20665d4
get content with gin
Moritz-Alexander-Kern Apr 18, 2024
5323039
use git clone
Moritz-Alexander-Kern Apr 18, 2024
9fa145c
use https
Moritz-Alexander-Kern Apr 18, 2024
2f4b8d0
add depth command to clone
Moritz-Alexander-Kern Apr 18, 2024
e6a34fd
change path
Moritz-Alexander-Kern Apr 18, 2024
ded0793
update gin commands
Moritz-Alexander-Kern Apr 18, 2024
22786b5
handle prompt
Moritz-Alexander-Kern Apr 19, 2024
66a1795
use datalad
Moritz-Alexander-Kern Apr 19, 2024
91f4a5a
remove typo
Moritz-Alexander-Kern Apr 19, 2024
669d80d
change paths
Moritz-Alexander-Kern Apr 19, 2024
0215b91
remove no longer needed var
Moritz-Alexander-Kern Apr 19, 2024
c30d022
add environment variable ELEPHANT_DATA_PATH
Moritz-Alexander-Kern Apr 19, 2024
4dd82d6
fix causality tests
Moritz-Alexander-Kern Apr 19, 2024
2d41c1a
fix tests for phase analysis
Moritz-Alexander-Kern Apr 19, 2024
5227f1d
fix tests causality
Moritz-Alexander-Kern Apr 19, 2024
bc0252b
fix tests spectral
Moritz-Alexander-Kern Apr 19, 2024
2f29dbe
fix tests spiketrain correlation
Moritz-Alexander-Kern Apr 19, 2024
247e951
fix tests spike train dissimilarity
Moritz-Alexander-Kern Apr 19, 2024
6b1e55f
fix tests spike train synchrony
Moritz-Alexander-Kern Apr 19, 2024
eed9062
Merge branch 'master' into enh/add_caching_action
Moritz-Alexander-Kern Apr 25, 2024
f71ced6
fix pep8
Moritz-Alexander-Kern Apr 25, 2024
e2382e6
fix pep8 test_spectral
Moritz-Alexander-Kern Apr 25, 2024
7791e52
fix pep8 test_spike_train_dissimilarity
Moritz-Alexander-Kern Apr 25, 2024
2f28e2a
use local data for elephant-data in macOS runner
Moritz-Alexander-Kern Apr 25, 2024
fc500e2
update elephant-data path
Moritz-Alexander-Kern Apr 25, 2024
983fc2c
update path
Moritz-Alexander-Kern Apr 25, 2024
3421fc3
add caching to pip runner
Moritz-Alexander-Kern Apr 25, 2024
3930826
try cache macos for ubuntu
Moritz-Alexander-Kern Apr 25, 2024
05d96e9
add local elephant-data to runner
Moritz-Alexander-Kern Apr 25, 2024
be2f9d4
update restore key
Moritz-Alexander-Kern Apr 25, 2024
98ea592
add ubuntu runner for caching
Moritz-Alexander-Kern Apr 25, 2024
33510ff
change permissions
Moritz-Alexander-Kern Apr 25, 2024
5b6f3f6
update datalad install for ubuntu
Moritz-Alexander-Kern Apr 25, 2024
b357e19
caches created
Moritz-Alexander-Kern Apr 25, 2024
617e09b
add cache only on hit
Moritz-Alexander-Kern Apr 26, 2024
9863b88
use latest packages
Moritz-Alexander-Kern Apr 26, 2024
d5b4279
handle caching with setup-python
Moritz-Alexander-Kern Apr 26, 2024
f8dad2a
fix typo
Moritz-Alexander-Kern Apr 26, 2024
9d46b34
add caching to toher runners
Moritz-Alexander-Kern Apr 26, 2024
f332fa6
add cache for windows
Moritz-Alexander-Kern Apr 26, 2024
fa98ff8
fix if cond
Moritz-Alexander-Kern Apr 26, 2024
8a89514
add windows runner
Moritz-Alexander-Kern Apr 26, 2024
c12ea49
fix typo
Moritz-Alexander-Kern Apr 26, 2024
d9bee54
change conditions
Moritz-Alexander-Kern Apr 26, 2024
168002d
fix formatting, cleanup
Moritz-Alexander-Kern Apr 26, 2024
7ae479a
add caching for windows runner
Moritz-Alexander-Kern Apr 26, 2024
41b7246
update path for winows
Moritz-Alexander-Kern Apr 26, 2024
bf4e03d
update setup python for windows
Moritz-Alexander-Kern Apr 26, 2024
fe20f4e
caching on windows runner with setup Python
Moritz-Alexander-Kern Apr 26, 2024
c45ca70
update caching for MPI
Moritz-Alexander-Kern Apr 26, 2024
c98440d
change if cond in caching
Moritz-Alexander-Kern Apr 26, 2024
93d13c8
remove PR trigger from caching action
Moritz-Alexander-Kern Apr 26, 2024
cca7bae
revert formatting for phase analysis
Moritz-Alexander-Kern Apr 26, 2024
24389c9
fix pep8 phase analysis
Moritz-Alexander-Kern Apr 26, 2024
4a41379
pep8
Moritz-Alexander-Kern Apr 26, 2024
767d8a9
reverse formatting, fix pep8
Moritz-Alexander-Kern Apr 26, 2024
0dd56d4
use one os for caching
Moritz-Alexander-Kern Jun 3, 2024
2b37f83
add trigger for workflow
Moritz-Alexander-Kern Jun 3, 2024
992d27d
use macos cache with win
Moritz-Alexander-Kern Jun 3, 2024
c5f7e3a
update cross os archive
Moritz-Alexander-Kern Jun 3, 2024
8253369
use caching for pip ubuntu runner
Moritz-Alexander-Kern Jun 3, 2024
8633409
add new caching for macOS
Moritz-Alexander-Kern Jun 3, 2024
a715ded
add caching for MPI runner
Moritz-Alexander-Kern Jun 3, 2024
a31e25a
add caching for Conda runners
Moritz-Alexander-Kern Jun 3, 2024
3631eaa
update setup python
Moritz-Alexander-Kern Jun 3, 2024
bd49d5a
update checkout action
Moritz-Alexander-Kern Jun 3, 2024
95efb0b
update macOS runner
Moritz-Alexander-Kern Jun 3, 2024
5fb913b
update miniconda setup
Moritz-Alexander-Kern Jun 3, 2024
936302e
add version cap for neo
Moritz-Alexander-Kern Jun 3, 2024
29c3f88
fix typo
Moritz-Alexander-Kern Jun 3, 2024
d78037f
add version cap for matplotlib
Moritz-Alexander-Kern Jun 3, 2024
c73431b
add version cap for matplotlib
Moritz-Alexander-Kern Jun 3, 2024
c34b893
update name of env variable
Moritz-Alexander-Kern Jun 3, 2024
0b180a8
do some clean up, change time of cron job
Moritz-Alexander-Kern Jun 3, 2024
512bcb4
clean up
Moritz-Alexander-Kern Jun 3, 2024
2102057
runner to create caches set to ubuntu
Moritz-Alexander-Kern Jun 11, 2024
2fb7fb0
Merge branch 'master' into enh/add_caching_action
Moritz-Alexander-Kern Jun 11, 2024
ae5d4c4
add test if path exists
Moritz-Alexander-Kern Jun 14, 2024
7de8853
add error for invalid data locations
Moritz-Alexander-Kern Jun 14, 2024
a1833c6
add tests for download_datasets function
Moritz-Alexander-Kern Jun 14, 2024
5774b20
Update requirements.txt
Moritz-Alexander-Kern Jun 28, 2024
ae8c636
remove trigger from caching action
Moritz-Alexander-Kern Jun 28, 2024
2fffb43
add version cap for scipy
Moritz-Alexander-Kern Jun 28, 2024
9cb7109
remove scipy version caps
Moritz-Alexander-Kern Jul 23, 2024
f6e6353
Merge branch 'master' into enh/add_caching_action
Moritz-Alexander-Kern Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 109 additions & 52 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,32 @@ jobs:
fail-fast: false

steps:
# used to reset cache every month
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: 'pip'
cache-dependency-path: '**/requirements.txt'
cache-dependency-path: |
**/requirements.txt
**/requirements-extras.txt
**/requirements-tests.txt

- name: Cache test_env
uses: actions/cache@v3
- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ${{ steps.pip-cache.outputs.dir }}
# Look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }}
-${{ steps.date.outputs.date }}
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
restore-keys: datasets-
enableCrossOsArchive: true

- name: Install dependencies
run: |
Expand All @@ -112,6 +110,11 @@ jobs:

- name: Test with pytest
run: |
if [ -d ~/elephant-data ]; then
export ELEPHANT_DATA_LOCATION=~/elephant-data
echo $ELEPHANT_DATA_LOCATION
fi

coverage run --source=elephant -m pytest
coveralls --service=github || echo "Coveralls submission failed"
env:
Expand Down Expand Up @@ -146,6 +149,19 @@ jobs:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{hashFiles('requirements/environment.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}

- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
restore-keys: datasets-

- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # corresponds to v3.0.4
with:
auto-update-conda: true
Expand Down Expand Up @@ -173,6 +189,10 @@ jobs:
- name: Test with pytest
shell: bash -l {0}
run: |
if [ -d ~/elephant-data ]; then
export ELEPHANT_DATA_LOCATION=~/elephant-data
echo $ELEPHANT_DATA_LOCATION
fi
pytest --cov=elephant

# __ ___ _
Expand All @@ -192,24 +212,32 @@ jobs:
os: [windows-latest]

steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: 'pip'
cache-dependency-path: |
**/requirements.txt
**/requirements-extras.txt
**/requirements-tests.txt

- name: Cache pip
uses: actions/cache@v3
- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ~\AppData\Local\pip\Cache
# Look to see if there is a cache hit for the corresponding requirements files
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
restore-keys: datasets-
enableCrossOsArchive: true

- name: Install dependencies
run: |
Expand All @@ -224,6 +252,10 @@ jobs:

- name: Test with pytest
run: |
if (Test-Path "$env:USERPROFILE\elephant-data") {
$env:ELEPHANT_DATA_LOCATION = "$env:USERPROFILE\elephant-data"
Write-Output $env:ELEPHANT_DATA_LOCATION
}
pytest --cov=elephant

# __ __ ____ ___
Expand All @@ -246,29 +278,32 @@ jobs:
fail-fast: false

steps:
- name: Get current year-month
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: 'pip'
cache-dependency-path: |
**/requirements.txt
**/requirements-extras.txt
**/requirements-tests.txt

- name: Get pip cache dir
id: pip-cache
- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- name: Cache test_env
uses: actions/cache@v3
- uses: actions/cache/restore@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ${{ steps.pip-cache.outputs.dir }}
# look to see if there is a cache hit for the corresponding requirements files
# cache will be reset on changes to any requirements or every month
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
restore-keys: datasets-
enableCrossOsArchive: true

- name: Setup environment
run: |
Expand All @@ -287,6 +322,10 @@ jobs:

- name: Test with pytest
run: |
if [ -d ~/elephant-data ]; then
export ELEPHANT_DATA_LOCATION=~/elephant-data
echo $ELEPHANT_DATA_LOCATION
fi
mpiexec -n 1 python -m mpi4py -m coverage run --source=elephant -m pytest
coveralls --service=github || echo "Coveralls submission failed"
env:
Expand Down Expand Up @@ -316,7 +355,7 @@ jobs:
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Get pip cache dir
id: pip-cache
Expand All @@ -330,6 +369,20 @@ jobs:

key: ${{ runner.os }}-pip-${{hashFiles('requirements/environment-tests.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}

- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
restore-keys: datasets-
enableCrossOsArchive: true

- uses: conda-incubator/setup-miniconda@030178870c779d9e5e1b4e563269f3aa69b04081 # corresponds to v3.0.3
with:
auto-update-conda: true
Expand Down Expand Up @@ -358,6 +411,10 @@ jobs:
- name: Test with pytest
shell: bash -el {0}
run: |
if [ -d ~/elephant-data ]; then
export ELEPHANT_DATA_LOCATION=~/elephant-data
echo $ELEPHANT_DATA_LOCATION
fi
pytest --cov=elephant

# ____
Expand All @@ -383,7 +440,7 @@ jobs:
id: date
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Get pip cache dir
id: pip-cache
Expand Down Expand Up @@ -448,10 +505,10 @@ jobs:
- name: Get current year-month
id: date
run: echo "::set-output name=date::$(date +'%Y-%m')"
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python-version }}

Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/cache_elephant_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Create caches for elephant_data

on:
workflow_dispatch: # Workflow can be triggered manually via GH actions webinterface
push: # When something is pushed into master this checks if caches need to re-created
branches:
- master
schedule:
- cron: "11 23 * * *" # Daily at 23:11 UTC


jobs:
create-data-cache-if-missing:
name: Caching data env
runs-on: ubuntu-latest
strategy:
# do not cancel all in-progress jobs if any matrix job fails
fail-fast: false

steps:
- name: Get current hash (SHA) of the elephant_data repo
id: elephant-data
run: |
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4.0.2
# Loading cache of elephant-data
id: cache-datasets
with:
path: ~/elephant-data
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}

- name: Cache found?
run: echo "Cache-hit == ${{steps.cache-datasets.outputs.cache-hit == 'true'}}"

- name: Configuring git
if: steps.cache-datasets.outputs.cache-hit != 'true'
run: |
git config --global user.email "elephant_ci@fake_mail.com"
git config --global user.name "elephant CI"
git config --global filter.annex.process "git-annex filter-process" # recommended for efficiency

- name: Install Datalad Linux
if: steps.cache-datasets.outputs.cache-hit != 'true'
run: |
python -m pip install -U pip # Official recommended way
pip install datalad-installer
datalad-installer --sudo ok git-annex --method datalad/packages
pip install datalad

- name: Download dataset
id: download-dataset
if: steps.cache-datasets.outputs.cache-hit != 'true'
# Download repository and also fetch data
run: |
cd ~
datalad --version
datalad install --recursive --get-data https://gin.g-node.org/NeuralEnsemble/elephant-data

- name: Show size of the cache to assert data is downloaded
run: |
cd ~
du -hs ~/elephant-data
ls -lh ~/elephant-data

Loading
Loading