Skip to content

Commit a0bba3a

Browse files
Merge pull request #1132 from samuelgarcia/remove_datalad_import
import datatlad only when running download_dataset()
2 parents 10c2884 + 2ad6f8f commit a0bba3a

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

neo/test/iotest/common_io_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333
from neo.test.rawiotest.tools import can_use_network
3434
from neo.test.rawiotest.common_rawio_test import repo_for_test
3535
from neo.utils import (download_dataset,
36-
get_local_testing_data_folder, HAVE_DATALAD)
36+
get_local_testing_data_folder)
3737

38+
try:
39+
import datalad
40+
HAVE_DATALAD = True
41+
except:
42+
HAVE_DATALAD = False
3843

3944
from neo.test.iotest.tools import (cleanup_test_file,
4045
close_object_safe, create_generic_io_object,

neo/test/rawiotest/common_rawio_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
import unittest
2222

2323
from neo.utils.datasets import (download_dataset,
24-
get_local_testing_data_folder, HAVE_DATALAD, default_testing_repo)
24+
get_local_testing_data_folder, default_testing_repo)
2525

2626
from neo.test.rawiotest.tools import can_use_network
2727

2828
from neo.test.rawiotest import rawio_compliance as compliance
2929

30+
try:
31+
import datalad
32+
HAVE_DATALAD = True
33+
except:
34+
HAVE_DATALAD = False
3035

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

neo/test/rawiotest/tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
import logging
66
import os
77

8-
from neo.utils import HAVE_DATALAD
9-
108
logger = logging.getLogger("neo.test")
119

1210

1311
def can_use_network():
1412
"""
1513
Return True if network access is allowed
1614
"""
15+
try:
16+
import datalad
17+
HAVE_DATALAD = True
18+
except:
19+
HAVE_DATALAD = False
1720
if not HAVE_DATALAD:
1821
return False
1922
if os.environ.get('NOSETESTS_NO_NETWORK', False):

neo/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
from .misc import (get_events, get_epochs, add_epoch,
66
match_events, cut_block_by_epochs, cut_segment_by_epoch,
77
is_block_rawio_compatible)
8-
from .datasets import (download_dataset,
9-
get_local_testing_data_folder, HAVE_DATALAD)
8+
from .datasets import download_dataset, get_local_testing_data_folder

neo/utils/datasets.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
import os
55
from pathlib import Path
66

7-
try:
8-
import datalad.api
9-
from datalad.support.gitrepo import GitRepo
10-
11-
HAVE_DATALAD = True
12-
except:
13-
HAVE_DATALAD = False
14-
157
default_testing_repo = 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data'
168

179
global local_testing_data_folder
@@ -59,7 +51,8 @@ def download_dataset(repo=default_testing_repo, remote_path=None,
5951
local_path:
6052
The local path of the downloaded file or folder
6153
"""
62-
assert HAVE_DATALAD, 'You need to install datalad'
54+
import datalad.api
55+
from datalad.support.gitrepo import GitRepo
6356

6457
if local_folder is None:
6558
global local_testing_data_folder

0 commit comments

Comments
 (0)