Skip to content

Commit 77455a0

Browse files
Merge pull request #984 from NeuralEnsemble/gh_actions_and_datalad
Gh actions and datalad
2 parents 072adfd + 140612f commit 77455a0

File tree

82 files changed

+840
-1237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+840
-1237
lines changed

.circleci/config.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.github/workflows/full-test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: neo.io and neo.rawio tests
2+
3+
on:
4+
pull_request:
5+
branches: [master, gh_actions_and_datalad]
6+
types: [synchronize, opened, reopened, ready_for_review]
7+
8+
jobs:
9+
build-and-test:
10+
name: Test on (${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
# "macos-latest", "windows-latest"
16+
os: ["ubuntu-latest", ]
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
python-version: 3.8
21+
- name: Get current year-month
22+
id: date
23+
run: echo "::set-output name=date::$(date+'%Y-%m')"
24+
- uses: actions/cache@v2
25+
# the cache for python package is reset:
26+
# * every month
27+
# * when requirements/requirements_testing change
28+
id: cache-venv
29+
with:
30+
path: ~/test_env
31+
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements_testing.txt') }}-${{ steps.date.outputs.date }}
32+
restore-keys: |
33+
${{ runner.os }}-venv-
34+
- name: Install dependencies
35+
run: |
36+
# this is for datalad and download testing datasets
37+
sudo apt install git git-annex
38+
# needed for correct operation of git/git-annex/DataLad
39+
git config --global user.email "neo_ci@fake_mail.com"
40+
git config --global user.name "neo CI"
41+
# create an environment and install everything
42+
python -m venv ~/test_env
43+
source ~/test_env/bin/activate
44+
python -m pip install --upgrade pip
45+
# pip install -r requirements.txt
46+
pip install -r requirements_testing.txt
47+
pip install -e .
48+
- name: Get ephy_testing_data current head hash
49+
# the key depend on the last comit repo https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git
50+
id: vars
51+
run: |
52+
echo "::set-output name=HASH_EPHY_DATASET::$(git ls-remote https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git HEAD | cut -f1)"
53+
- uses: actions/cache@v2
54+
id: cache-datasets
55+
with:
56+
path: ~/ephy_testing_data
57+
key: ${{ runner.os }}-datasets-${{ steps.vars.outputs.HASH_EPHY_DATASET }}
58+
restore-keys: |
59+
${{ runner.os }}-datasets
60+
- name: Test with pytest
61+
run: |
62+
source ~/test_env/bin/activate
63+
# only neo.rawio and neo.io
64+
pytest --cov=neo neo/test/rawiotest
65+
pytest --cov=neo neo/test/iotest

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ before_install:
3030
- pip install "numpy==$NUMPY_VERSION"
3131
install:
3232
- pip install -r requirements.txt
33+
- pip install nose
3334
- pip install coveralls
3435
- pip install .
3536
- pip install pillow

neo/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
logging_handler = logging.StreamHandler()
99

1010
from neo.core import *
11-
# ~ import neo.rawio
1211
from neo.io import *
1312

1413
from neo.version import version as __version__

neo/io/kwikio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ def read_spiketrain(self, cluster_id, model,
198198
w = pq.Quantity(w, raw_data_units)
199199
else:
200200
w = None
201+
if model.duration > 0.:
202+
t_stop = model.duration
203+
else:
204+
t_stop = np.max(model.spike_times[idx])
201205
sptr = SpikeTrain(times=model.spike_times[idx],
202-
t_stop=model.duration, waveforms=w, units='s',
206+
t_stop=t_stop, waveforms=w, units='s',
203207
sampling_rate=model.sample_rate * pq.Hz,
204208
file_origin=self.filename,
205209
**{'cluster_id': cluster_id})

neo/rawio/baserawio.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
('offset', 'float64'),
7777
('stream_id', 'U64'),
7878
]
79+
7980
# TODO for later: add t_start and length in _signal_channel_dtype
8081
# this would simplify all t_start/t_stop stuff for each RawIO class
8182

neo/test/iotest/common_io_test.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
assert_sub_schema_is_lazy_loaded,
3030
assert_children_empty)
3131

32-
from neo.test.rawiotest.tools import (can_use_network, make_all_directories,
33-
download_test_file, create_local_temp_dir)
32+
from neo.test.rawiotest.tools import can_use_network
33+
from neo.test.rawiotest.common_rawio_test import repo_for_test
34+
from neo.utils import (download_dataset,
35+
get_local_testing_data_folder, HAVE_DATALAD)
36+
3437

3538
from neo.test.iotest.tools import (cleanup_test_file,
3639
close_object_safe, create_generic_io_object,
@@ -40,11 +43,8 @@
4043
iter_generic_readers, iter_read_objects,
4144
read_generic,
4245
write_generic)
43-
from neo.test.generate_datasets import generate_from_supported_objects
44-
4546

46-
# url_for_tests = "https://portal.g-node.org/neo/" #This is the old place
47-
url_for_tests = "https://web.gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/"
47+
from neo.test.generate_datasets import generate_from_supported_objects
4848

4949

5050
class BaseTestIO:
@@ -67,8 +67,8 @@ class BaseTestIO:
6767
# all IO test need to modify this:
6868
ioclass = None # the IOclass to be tested
6969

70-
files_to_test = [] # list of files to test compliances
71-
files_to_download = [] # when files are at G-Node
70+
entities_to_test = [] # list of files to test compliances
71+
entities_to_download = [] # when files are at gin
7272

7373
# when reading then writing produces files with identical hashes
7474
hash_conserved_when_write_read = False
@@ -84,7 +84,6 @@ def setUp(self):
8484
'''
8585
Set up the test fixture. This is run for every test
8686
'''
87-
self.files_to_test = copy(self.__class__.files_to_test)
8887
self.higher = self.ioclass.supported_objects[0]
8988
self.shortname = self.ioclass.__name__.lower().rstrip('io')
9089
# these objects can both be written and read
@@ -93,11 +92,19 @@ def setUp(self):
9392
# these objects can be either written or read
9493
self.io_readorwrite = list(set(self.ioclass.readable_objects) |
9594
set(self.ioclass.writeable_objects))
96-
self.create_local_dir_if_not_exists()
97-
self.download_test_files_if_not_present()
98-
self.files_generated = []
99-
self.generate_files_for_io_able_to_write()
100-
self.files_to_test.extend(self.files_generated)
95+
96+
if HAVE_DATALAD:
97+
for remote_path in self.entities_to_download:
98+
download_dataset(repo=repo_for_test, remote_path=remote_path)
99+
100+
self.files_generated = []
101+
self.generate_files_for_io_able_to_write()
102+
103+
# be carefull self.entities_to_test is class attributes
104+
self.files_to_test = [self.get_local_path(e) for e in self.entities_to_test]
105+
else:
106+
self.files_to_test = []
107+
raise unittest.SkipTest("Requires datalad download of data from the web")
101108

102109
def create_local_dir_if_not_exists(self):
103110
'''
@@ -169,11 +176,15 @@ def able_to_write_or_read(self, writeread=False, readwrite=False):
169176

170177
return True
171178

172-
def get_filename_path(self, filename):
173-
'''
174-
Get the path to a filename in the current temporary file directory
175-
'''
176-
return os.path.join(self.local_test_dir, filename)
179+
def get_local_base_folder(self):
180+
return get_local_testing_data_folder()
181+
182+
def get_local_path(self, sub_path):
183+
root_local_path = self.get_local_base_folder()
184+
local_path = root_local_path / sub_path
185+
# TODO later : remove the str when all IOs handle the pathlib.Path objects
186+
local_path = str(local_path)
187+
return local_path
177188

178189
def generic_io_object(self, filename=None, return_path=False, clean=False):
179190
'''

neo/test/iotest/test_alphaomegaio.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99

1010

1111
class TestAlphaOmegaIO(BaseTestIO, unittest.TestCase):
12-
files_to_test = ['File_AlphaOmega_1.map',
13-
'File_AlphaOmega_2.map']
14-
files_to_download = files_to_test
12+
entities_to_download =[
13+
'alphaomega'
14+
]
15+
entities_to_test = [
16+
'alphaomega/File_AlphaOmega_1.map',
17+
'alphaomega/File_AlphaOmega_2.map'
18+
]
1519
ioclass = AlphaOmegaIO
1620

1721

neo/test/iotest/test_asciisignalio.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
class TestAsciiSignalIOWithTestFiles(BaseTestIO, unittest.TestCase):
1818
ioclass = AsciiSignalIO
19-
files_to_download = [ # 'File_asciisignal_1.asc',
20-
'File_asciisignal_2.txt',
21-
'File_asciisignal_3.txt',
19+
entities_to_download = [
20+
'asciisignal'
21+
]
22+
entities_to_test = [
23+
'asciisignal/File_asciisignal_2.txt',
24+
'asciisignal/File_asciisignal_3.txt',
2225
]
23-
files_to_test = files_to_download
2426

2527

2628
class TestAsciiSignalIO(unittest.TestCase):

neo/test/iotest/test_asciispiketrainio.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
class TestAsciiSpikeTrainIO(BaseTestIO, unittest.TestCase, ):
1212
ioclass = AsciiSpikeTrainIO
13-
files_to_download = ['File_ascii_spiketrain_1.txt']
14-
files_to_test = files_to_download
13+
entities_to_download = [
14+
'asciispiketrain'
15+
]
16+
entities_to_test = [
17+
'asciispiketrain/File_ascii_spiketrain_1.txt',
18+
]
1519

1620

1721
if __name__ == "__main__":

0 commit comments

Comments
 (0)