Skip to content

Commit b2a358a

Browse files
authored
Fix ci testing-datalad install for python 3.12 + git-annex (#1667)
* fix ci testing * test si way of installing datalad * Revert "test si way of installing datalad" This reverts commit a6463be. * another attempt to get datalad to work * oops * add comments * from warning to ci error (Heberto feedback)
1 parent 07fa5b3 commit b2a358a

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

.github/workflows/io-test.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,25 @@ jobs:
7676
# restore-key hits should result in `cache-hit` == 'false'
7777
#if: steps.cache-conda-env.outputs.cache-hit != 'true'
7878
run: |
79-
conda install datalad pip numpy=${{ matrix.numpy-version }} -c conda-forge
79+
conda install pip numpy=${{ matrix.numpy-version }} -c conda-forge
8080
# this command is for updating cache. We are resting removal.
8181
# conda env update --name neo-test-env-${{ matrix.python-version }} --file environment_testing.yml --prune
8282

83+
- name: Install git-annex
84+
# this is the trick from the spikeinterface repo for getting git-annex to work with datalad
85+
shell: bash
86+
run: |
87+
pip install datalad-installer
88+
wget https://downloads.kitenet.net/git-annex/linux/current/git-annex-standalone-amd64.tar.gz
89+
mkdir /home/runner/work/installation
90+
mv git-annex-standalone-amd64.tar.gz /home/runner/work/installation/
91+
workdir=$(pwd)
92+
cd /home/runner/work/installation
93+
tar xvzf git-annex-standalone-amd64.tar.gz
94+
echo "$(pwd)/git-annex.linux" >> $GITHUB_PATH
95+
cd $workdir
96+
git config --global filter.annex.process "git-annex filter-process" # recommended for efficiency
97+
8398
- name: Configure git
8499
run: |
85100
git config --global user.email "neo_ci@fake_mail.com"

neo/test/rawiotest/common_rawio_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,27 @@
1919

2020
import logging
2121
import unittest
22+
import importlib.util
23+
import warnings
24+
import os
2225

2326
from neo.utils.datasets import download_dataset, get_local_testing_data_folder, default_testing_repo
2427

2528
from neo.test.rawiotest.tools import can_use_network
2629

2730
from neo.test.rawiotest import rawio_compliance as compliance
2831

29-
try:
30-
import datalad
31-
32+
datalad_spec = importlib.util.find_spec("datalad")
33+
if datalad_spec is not None:
3234
HAVE_DATALAD = True
33-
except:
35+
else:
3436
HAVE_DATALAD = False
37+
# pytest skip doesn't explain why we are skipping.
38+
# raise error if in CI to prevent tests from spuriously skipping and appearing
39+
# as passing.
40+
if os.environ.get("GITHUB_ACTIONS") == 'true':
41+
raise RuntimeError("Datalad is required for running the CI.")
42+
3543

3644
# url_for_tests = "https://portal.g-node.org/neo/" #This is the old place
3745
repo_for_test = default_testing_repo

neo/test/rawiotest/tools.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import logging
66
import os
7+
import importlib.util
8+
79

810
logger = logging.getLogger("neo.test")
911

@@ -13,14 +15,18 @@ def can_use_network():
1315
Return True if network access is allowed
1416
"""
1517

18+
# env variable for local dev
1619
if os.environ.get("NEO_TESTS_NO_NETWORK", False):
1720
return False
18-
try:
19-
import datalad
20-
21+
22+
# check for datalad presence
23+
datalad_spec = importlib.util.find_spec("datalad")
24+
if datalad_spec is not None:
2125
HAVE_DATALAD = True
22-
except:
26+
else:
2327
HAVE_DATALAD = False
28+
2429
if not HAVE_DATALAD:
2530
return False
31+
2632
return True

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test = [
4949
# "dhn_med_py<2.0", # ci failing with 2.0 test future version when stable
5050
"pytest",
5151
"pytest-cov",
52-
# datalad # this dependency is covered by conda (environment_testing.yml)-- maybe moving straight to ci
52+
"datalad",
5353
"scipy>=1.0.0",
5454
"pyedflib",
5555
"h5py",

0 commit comments

Comments
 (0)