Skip to content

Commit caa10f4

Browse files
Merge branch 'master' into enh/spike_extraction_documentation
2 parents be21820 + 123ca04 commit caa10f4

14 files changed

+373
-178
lines changed

.github/workflows/CI.yml

Lines changed: 109 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -70,34 +70,32 @@ jobs:
7070
fail-fast: false
7171

7272
steps:
73-
# used to reset cache every month
74-
- name: Get current year-month
75-
id: date
76-
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
77-
78-
- name: Get pip cache dir
79-
id: pip-cache
80-
run: |
81-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
82-
83-
- uses: actions/checkout@v3
73+
- uses: actions/[email protected]
8474

8575
- name: Set up Python ${{ matrix.python-version }}
86-
uses: actions/setup-python@v4
76+
uses: actions/setup-python@v5.1.0
8777
with:
8878
python-version: ${{ matrix.python-version }}
79+
check-latest: true
8980
cache: 'pip'
90-
cache-dependency-path: '**/requirements.txt'
81+
cache-dependency-path: |
82+
**/requirements.txt
83+
**/requirements-extras.txt
84+
**/requirements-tests.txt
9185
92-
- name: Cache test_env
93-
uses: actions/cache@v3
86+
- name: Get current hash (SHA) of the elephant_data repo
87+
id: elephant-data
88+
run: |
89+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
90+
91+
- uses: actions/cache/[email protected]
92+
# Loading cache of elephant-data
93+
id: cache-datasets
9494
with:
95-
path: ${{ steps.pip-cache.outputs.dir }}
96-
# Look to see if there is a cache hit for the corresponding requirements files
97-
# cache will be reset on changes to any requirements or every month
98-
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
99-
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('**/CI.yml') }}-${{ hashFiles('setup.py') }}
100-
-${{ steps.date.outputs.date }}
95+
path: ~/elephant-data
96+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
97+
restore-keys: datasets-
98+
enableCrossOsArchive: true
10199

102100
- name: Install dependencies
103101
run: |
@@ -112,6 +110,11 @@ jobs:
112110
113111
- name: Test with pytest
114112
run: |
113+
if [ -d ~/elephant-data ]; then
114+
export ELEPHANT_DATA_LOCATION=~/elephant-data
115+
echo $ELEPHANT_DATA_LOCATION
116+
fi
117+
115118
coverage run --source=elephant -m pytest
116119
coveralls --service=github || echo "Coveralls submission failed"
117120
env:
@@ -146,6 +149,19 @@ jobs:
146149
path: ~/conda_pkgs_dir
147150
key: ${{ runner.os }}-conda-${{hashFiles('requirements/environment.yml') }}-${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
148151

152+
- name: Get current hash (SHA) of the elephant_data repo
153+
id: elephant-data
154+
run: |
155+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
156+
157+
- uses: actions/cache/[email protected]
158+
# Loading cache of elephant-data
159+
id: cache-datasets
160+
with:
161+
path: ~/elephant-data
162+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
163+
restore-keys: datasets-
164+
149165
- uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # corresponds to v3.0.4
150166
with:
151167
auto-update-conda: true
@@ -173,6 +189,10 @@ jobs:
173189
- name: Test with pytest
174190
shell: bash -l {0}
175191
run: |
192+
if [ -d ~/elephant-data ]; then
193+
export ELEPHANT_DATA_LOCATION=~/elephant-data
194+
echo $ELEPHANT_DATA_LOCATION
195+
fi
176196
pytest --cov=elephant
177197
178198
# __ ___ _
@@ -192,24 +212,32 @@ jobs:
192212
os: [windows-latest]
193213

194214
steps:
195-
- name: Get current year-month
196-
id: date
197-
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
198-
199-
- uses: actions/checkout@v3
215+
- uses: actions/[email protected]
200216

201217
- name: Set up Python ${{ matrix.python-version }}
202-
uses: actions/setup-python@v4
218+
uses: actions/setup-python@v5.1.0
203219
with:
204220
python-version: ${{ matrix.python-version }}
221+
check-latest: true
222+
cache: 'pip'
223+
cache-dependency-path: |
224+
**/requirements.txt
225+
**/requirements-extras.txt
226+
**/requirements-tests.txt
205227
206-
- name: Cache pip
207-
uses: actions/cache@v3
228+
- name: Get current hash (SHA) of the elephant_data repo
229+
id: elephant-data
230+
run: |
231+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
232+
233+
- uses: actions/cache/[email protected]
234+
# Loading cache of elephant-data
235+
id: cache-datasets
208236
with:
209-
path: ~\AppData\Local\pip\Cache
210-
# Look to see if there is a cache hit for the corresponding requirements files
211-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
212-
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
237+
path: ~/elephant-data
238+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
239+
restore-keys: datasets-
240+
enableCrossOsArchive: true
213241

214242
- name: Install dependencies
215243
run: |
@@ -224,6 +252,10 @@ jobs:
224252
225253
- name: Test with pytest
226254
run: |
255+
if (Test-Path "$env:USERPROFILE\elephant-data") {
256+
$env:ELEPHANT_DATA_LOCATION = "$env:USERPROFILE\elephant-data"
257+
Write-Output $env:ELEPHANT_DATA_LOCATION
258+
}
227259
pytest --cov=elephant
228260
229261
# __ __ ____ ___
@@ -246,29 +278,32 @@ jobs:
246278
fail-fast: false
247279

248280
steps:
249-
- name: Get current year-month
250-
id: date
251-
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
252-
- uses: actions/checkout@v3
281+
- uses: actions/[email protected]
253282

254283
- name: Set up Python ${{ matrix.python-version }}
255-
uses: actions/setup-python@v4
284+
uses: actions/setup-python@v5.1.0
256285
with:
257286
python-version: ${{ matrix.python-version }}
287+
check-latest: true
288+
cache: 'pip'
289+
cache-dependency-path: |
290+
**/requirements.txt
291+
**/requirements-extras.txt
292+
**/requirements-tests.txt
258293
259-
- name: Get pip cache dir
260-
id: pip-cache
294+
- name: Get current hash (SHA) of the elephant_data repo
295+
id: elephant-data
261296
run: |
262-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
297+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
263298
264-
- name: Cache test_env
265-
uses: actions/cache@v3
299+
- uses: actions/cache/[email protected]
300+
# Loading cache of elephant-data
301+
id: cache-datasets
266302
with:
267-
path: ${{ steps.pip-cache.outputs.dir }}
268-
# look to see if there is a cache hit for the corresponding requirements files
269-
# cache will be reset on changes to any requirements or every month
270-
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-tests.txt') }}
271-
-${{ hashFiles('**/requirements-extras.txt') }}-${{ hashFiles('setup.py') }} -${{ hashFiles('**/CI.yml') }}-${{ steps.date.outputs.date }}
303+
path: ~/elephant-data
304+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
305+
restore-keys: datasets-
306+
enableCrossOsArchive: true
272307

273308
- name: Setup environment
274309
run: |
@@ -287,6 +322,10 @@ jobs:
287322
288323
- name: Test with pytest
289324
run: |
325+
if [ -d ~/elephant-data ]; then
326+
export ELEPHANT_DATA_LOCATION=~/elephant-data
327+
echo $ELEPHANT_DATA_LOCATION
328+
fi
290329
mpiexec -n 1 python -m mpi4py -m coverage run --source=elephant -m pytest
291330
coveralls --service=github || echo "Coveralls submission failed"
292331
env:
@@ -316,7 +355,7 @@ jobs:
316355
id: date
317356
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
318357

319-
- uses: actions/checkout@v3
358+
- uses: actions/checkout@v4.1.6
320359

321360
- name: Get pip cache dir
322361
id: pip-cache
@@ -330,6 +369,20 @@ jobs:
330369

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

372+
- name: Get current hash (SHA) of the elephant_data repo
373+
id: elephant-data
374+
run: |
375+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
376+
377+
- uses: actions/cache/[email protected]
378+
# Loading cache of elephant-data
379+
id: cache-datasets
380+
with:
381+
path: ~/elephant-data
382+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
383+
restore-keys: datasets-
384+
enableCrossOsArchive: true
385+
333386
- uses: conda-incubator/setup-miniconda@030178870c779d9e5e1b4e563269f3aa69b04081 # corresponds to v3.0.3
334387
with:
335388
auto-update-conda: true
@@ -358,6 +411,10 @@ jobs:
358411
- name: Test with pytest
359412
shell: bash -el {0}
360413
run: |
414+
if [ -d ~/elephant-data ]; then
415+
export ELEPHANT_DATA_LOCATION=~/elephant-data
416+
echo $ELEPHANT_DATA_LOCATION
417+
fi
361418
pytest --cov=elephant
362419
363420
# ____
@@ -383,7 +440,7 @@ jobs:
383440
id: date
384441
run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
385442

386-
- uses: actions/checkout@v3
443+
- uses: actions/checkout@v4.1.6
387444

388445
- name: Get pip cache dir
389446
id: pip-cache
@@ -448,10 +505,10 @@ jobs:
448505
- name: Get current year-month
449506
id: date
450507
run: echo "::set-output name=date::$(date +'%Y-%m')"
451-
- uses: actions/checkout@v3
508+
- uses: actions/checkout@v4.1.6
452509

453510
- name: Set up Python ${{ matrix.python-version }}
454-
uses: actions/setup-python@v4
511+
uses: actions/setup-python@v5.1.0
455512
with:
456513
python-version: ${{ matrix.python-version }}
457514

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Create caches for elephant_data
2+
3+
on:
4+
workflow_dispatch: # Workflow can be triggered manually via GH actions webinterface
5+
push: # When something is pushed into master this checks if caches need to re-created
6+
branches:
7+
- master
8+
schedule:
9+
- cron: "11 23 * * *" # Daily at 23:11 UTC
10+
11+
12+
jobs:
13+
create-data-cache-if-missing:
14+
name: Caching data env
15+
runs-on: ubuntu-latest
16+
strategy:
17+
# do not cancel all in-progress jobs if any matrix job fails
18+
fail-fast: false
19+
20+
steps:
21+
- name: Get current hash (SHA) of the elephant_data repo
22+
id: elephant-data
23+
run: |
24+
echo "dataset_hash=$(git ls-remote https://gin.g-node.org/NeuralEnsemble/elephant-data.git HEAD | cut -f1)" >> $GITHUB_OUTPUT
25+
26+
- uses: actions/[email protected]
27+
# Loading cache of elephant-data
28+
id: cache-datasets
29+
with:
30+
path: ~/elephant-data
31+
key: datasets-${{ steps.elephant-data.outputs.dataset_hash }}
32+
33+
- name: Cache found?
34+
run: echo "Cache-hit == ${{steps.cache-datasets.outputs.cache-hit == 'true'}}"
35+
36+
- name: Configuring git
37+
if: steps.cache-datasets.outputs.cache-hit != 'true'
38+
run: |
39+
git config --global user.email "elephant_ci@fake_mail.com"
40+
git config --global user.name "elephant CI"
41+
git config --global filter.annex.process "git-annex filter-process" # recommended for efficiency
42+
43+
- name: Install Datalad Linux
44+
if: steps.cache-datasets.outputs.cache-hit != 'true'
45+
run: |
46+
python -m pip install -U pip # Official recommended way
47+
pip install datalad-installer
48+
datalad-installer --sudo ok git-annex --method datalad/packages
49+
pip install datalad
50+
51+
- name: Download dataset
52+
id: download-dataset
53+
if: steps.cache-datasets.outputs.cache-hit != 'true'
54+
# Download repository and also fetch data
55+
run: |
56+
cd ~
57+
datalad --version
58+
datalad install --recursive --get-data https://gin.g-node.org/NeuralEnsemble/elephant-data
59+
60+
- name: Show size of the cache to assert data is downloaded
61+
run: |
62+
cd ~
63+
du -hs ~/elephant-data
64+
ls -lh ~/elephant-data
65+

elephant/conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ def to_spike_trains(self, spikes="random", as_array=False,
854854
array_ants = dict(bins=bin_indices)
855855
spiketrain = neo.SpikeTrain(spiketrain, t_start=self._t_start,
856856
t_stop=self._t_stop,
857-
units=self.units, copy=False,
857+
units=self.units,
858858
description=description,
859859
array_annotations=array_ants,
860860
bin_size=self.bin_size)

0 commit comments

Comments
 (0)