Skip to content

Commit c42a7b7

Browse files
adam2392drammock
andauthored
[MAINT, MRG] Enable pooch to perform fetching of datasets (mne-tools#9742)
* Adding updated checksum * Initial try * Fix import * Fix check * Fix GH Actions * Try again to fix CI * make brainstorm work * Address comments initially * Removed _fetch_file dependency * Remove fetch file entirely * Lets go again with updated deletion * Try again with testing reqs * Try again * Fix test constants * Fix docs * fix unclosed resource warning (checksum registry) * make compatible with py3.7 * fix CIs? * Fixed all unit tests * Fix spell check * Fix sys * Adding updated checksum * Initial try * Fix import * Fix check * Fix GH Actions * Try again to fix CI * make brainstorm work * Address comments initially * Removed _fetch_file dependency * Remove fetch file entirely * Lets go again with updated deletion * Try again with testing reqs * Try again * Fix test constants * Fix docs * fix unclosed resource warning (checksum registry) * make compatible with py3.7 * fix CIs? * Fixed all unit tests * Fix spell check * Fix sys * purge importlib_resources and add _resource_path util function * Apply suggestions from code review * Fix flake * Update requirements_testing.txt * restore pooch to testing reqs * Nested import for pooch * Add back in * Fix resoure warning Co-authored-by: Daniel McCloy <dan@mccloy.info>
1 parent 034ff3f commit c42a7b7

35 files changed

+3931
-842
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ recursive-include mne/data/fsaverage *
2121
include mne/datasets/_fsaverage/root.txt
2222
include mne/datasets/_fsaverage/bem.txt
2323
include mne/datasets/_infant/*.txt
24+
include mne/data/dataset_checksums.txt
25+
include mne/data/eegbci_checksums.txt
2426

2527
recursive-include mne/channels/data/layouts *
2628
recursive-include mne/channels/data/montages *

doc/changes/latest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Enhancements
165165

166166
- Add :func:`mne.gui.locate_ieeg` to locate intracranial electrode contacts from a CT, an MRI (with Freesurfer ``recon-all``) and the channel names from an :class:`mne.Info` object (:gh:`9586` by `Alex Rockhill`_)
167167

168+
- All data fetching code now relies on ``pooch``, which is an added optional requirement for dataset fetchers (:gh:`9742` by `Adam Li`_ and `Daniel McCloy`_)
169+
168170
Bugs
169171
~~~~
170172
- Fix bug in :meth:`mne.io.Raw.pick` and related functions when parameter list contains channels which are not in info instance (:gh:`9708` **by new contributor** |Evgeny Goldstein|_)

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ dependencies:
3737
- mne
3838
- mffpy>=0.5.7
3939
- ipywidgets
40+
- pooch
4041
- pip:
4142
- ipyvtklink

mne/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ def _fail(*args, **kwargs):
613613
@pytest.fixture(scope='function')
614614
def download_is_error(monkeypatch):
615615
"""Prevent downloading by raising an error when it's attempted."""
616-
monkeypatch.setattr(mne.utils.fetching, '_get_http', _fail)
616+
import pooch
617+
monkeypatch.setattr(pooch, 'retrieve', _fail)
617618

618619

619620
@pytest.fixture()

mne/data/dataset_checksums.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# include here the name of the zipped file and the md5 hash
2+
# Note: other hashing algorithms can be enforced
3+
MNE-fNIRS-motor-data.tgz md5:c4935d19ddab35422a69f3326a01fef8
4+
MNE-kiloword-data.tar.gz md5:3a124170795abbd2e48aae8727e719a8
5+
MNE-multimodal-data.tar.gz md5:26ec847ae9ab80f58f204d09e2c08367
6+
MNE-OPM-data.tar.gz md5:370ad1dcfd5c47e029e692c85358a374
7+
MNE-phantom-4DBTi.zip md5:938a601440f3ffa780d20a17bae039ff
8+
MNE-sample-data-processed.tar.gz md5:12b75d1cb7df9dfb4ad73ed82f61094f
9+
MNE-somato-data.tar.gz md5:32fd2f6c8c7eb0784a1de6435273c48b
10+
MNE-spm-face.tar.gz md5:9f43f67150e3b694b523a21eb929ea75
11+
MNE-visual_92_categories-data-part1.tar.gz md5:74f50bbeb65740903eadc229c9fa759f
12+
MNE-visual_92_categories-data-part2.tar.gz md5:203410a98afc9df9ae8ba9f933370e20
13+
mTRF_1.5.zip md5:273a390ebbc48da2c3184b01a82e4636
14+
sample_reference_MEG_noise-raw.zip md5:779fecd890d98b73a4832e717d7c7c45
15+
ssvep_example_data.zip md5:af866bbc0f921114ac9d683494fe87d6
16+
MNE-ERP-CORE-data.tar.gz md5:5866c0d6213bd7ac97f254c776f6c4b1
17+
MNE-epilepsy-ecog-data.tar.gz md5:ffb139174afa0f71ec98adbbb1729dea
18+
19+
# Fieldtrip CMC dataset
20+
SubjectCMC.zip md5:6f9fd6520f9a66e20994423808d2528c
21+
22+
# brainstorm datasets:
23+
bst_auditory.tar.gz md5:fa371a889a5688258896bfa29dd1700b
24+
bst_phantom_ctf.tar.gz md5:80819cb7f5b92d1a5289db3fb6acb33c
25+
bst_phantom_elekta.tar.gz md5:1badccbe17998d18cc373526e86a7aaf
26+
bst_raw.tar.gz md5:fa2efaaec3f3d462b319bc24898f440c
27+
bst_resting.tar.gz md5:70fc7bf9c3b97c4f2eab6260ee4a0430
28+
29+
# HF-SEF
30+
hf_sef_raw.tar.gz md5:33934351e558542bafa9b262ac071168
31+
hf_sef_evoked.tar.gz md5:13d34cb5db584e00868677d8fb0aab2b
32+
33+
# "fake" dataset (for testing)
34+
foo.tgz md5:3194e9f7b46039bb050a74f3e1ae9908
35+
36+
# FreeSurfer files
37+
lh.aparc_sub.annot md5:9e4d8d6b90242b7e4b0145353436ef77
38+
rh.aparc_sub.annot md5:dd6464db8e7762d969fc1d8087cd211b
39+
40+
# below, do **not** include the release
41+
# number in the names of the testing or
42+
# misc datasets (it gets done automatically
43+
# in mne/datasets/utils.py). Only update
44+
# the md5 hashes as needed.
45+
mne-testing-data md5:db07710c0b94476f954f60926685b5b7
46+
mne-misc-data md5:0aa25a9bb4f204b3d4769f0b84e9b526

mne/data/eegbci_checksums.txt

Lines changed: 3058 additions & 0 deletions
Large diffs are not rendered by default.

mne/datasets/brainstorm/bst_auditory.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..utils import (has_dataset, _data_path, _get_version, _version_doc,
99
_data_path_doc_accept)
1010

11-
has_brainstorm_data = partial(has_dataset, name='brainstorm.bst_auditory')
11+
has_brainstorm_data = partial(has_dataset, name='bst_auditory')
1212

1313

1414
_description = u"""
@@ -31,9 +31,8 @@
3131
def data_path(path=None, force_update=False, update_path=True, download=True,
3232
*, accept=False, verbose=None): # noqa: D103
3333
return _data_path(path=path, force_update=force_update,
34-
update_path=update_path, name='brainstorm',
35-
download=download, archive_name='bst_auditory.tar.gz',
36-
accept=accept)
34+
update_path=update_path, name='bst_auditory',
35+
download=download, accept=accept)
3736

3837

3938
_data_path_doc = _data_path_doc_accept.format(
@@ -44,7 +43,7 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
4443

4544

4645
def get_version(): # noqa: D103
47-
return _get_version('brainstorm.bst_auditory')
46+
return _get_version('bst_auditory')
4847

4948

5049
get_version.__doc__ = _version_doc.format(name='brainstorm')

mne/datasets/brainstorm/bst_phantom_ctf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..utils import (has_dataset, _data_path, _get_version, _version_doc,
99
_data_path_doc_accept)
1010

11-
has_brainstorm_data = partial(has_dataset, name='brainstorm.bst_phantom_ctf')
11+
has_brainstorm_data = partial(has_dataset, name='bst_phantom_ctf')
1212

1313

1414
_description = u"""
@@ -20,9 +20,8 @@
2020
def data_path(path=None, force_update=False, update_path=True, download=True,
2121
*, accept=False, verbose=None): # noqa: D103
2222
return _data_path(path=path, force_update=force_update,
23-
update_path=update_path, name='brainstorm',
24-
download=download, archive_name='bst_phantom_ctf.tar.gz',
25-
accept=accept)
23+
update_path=update_path, name='bst_phantom_ctf',
24+
download=download, accept=accept)
2625

2726

2827
_data_path_doc = _data_path_doc_accept.format(
@@ -33,7 +32,7 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
3332

3433

3534
def get_version(): # noqa: D103
36-
return _get_version('brainstorm.bst_phantom_ctf')
35+
return _get_version('bst_phantom_ctf')
3736

3837

3938
get_version.__doc__ = _version_doc.format(name='brainstorm')

mne/datasets/brainstorm/bst_phantom_elekta.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
_data_path_doc_accept)
1010

1111
has_brainstorm_data = partial(has_dataset,
12-
name='brainstorm.bst_phantom_elekta')
12+
name='bst_phantom_elekta')
1313

1414

1515
_description = u"""
@@ -21,10 +21,8 @@
2121
def data_path(path=None, force_update=False, update_path=True, download=True,
2222
*, accept=False, verbose=None): # noqa: D103
2323
return _data_path(path=path, force_update=force_update,
24-
update_path=update_path, name='brainstorm',
25-
download=download,
26-
archive_name='bst_phantom_elekta.tar.gz',
27-
accept=accept)
24+
update_path=update_path, name='bst_phantom_elekta',
25+
download=download, accept=accept)
2826

2927

3028
_data_path_doc = _data_path_doc_accept.format(
@@ -36,7 +34,7 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
3634

3735

3836
def get_version(): # noqa: D103
39-
return _get_version('brainstorm.bst_phantom_elekta')
37+
return _get_version('bst_phantom_elekta')
4038

4139

4240
get_version.__doc__ = _version_doc.format(name='brainstorm')

mne/datasets/brainstorm/bst_raw.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..utils import (has_dataset, _data_path, _get_version, _version_doc,
99
_data_path_doc_accept)
1010

11-
has_brainstorm_data = partial(has_dataset, name='brainstorm.bst_raw')
11+
has_brainstorm_data = partial(has_dataset, name='bst_raw')
1212

1313
_description = u"""
1414
URL: http://neuroimage.usc.edu/brainstorm/DatasetMedianNerveCtf
@@ -29,9 +29,8 @@
2929
def data_path(path=None, force_update=False, update_path=True, download=True,
3030
*, accept=False, verbose=None): # noqa: D103
3131
return _data_path(path=path, force_update=force_update,
32-
update_path=update_path, name='brainstorm',
33-
download=download, archive_name='bst_raw.tar.gz',
34-
accept=accept)
32+
update_path=update_path, name='bst_raw',
33+
download=download, accept=accept)
3534

3635

3736
_data_path_doc = _data_path_doc_accept.format(
@@ -42,7 +41,7 @@ def data_path(path=None, force_update=False, update_path=True, download=True,
4241

4342

4443
def get_version(): # noqa: D103
45-
return _get_version('brainstorm.bst_raw')
44+
return _get_version('bst_raw')
4645

4746

4847
get_version.__doc__ = _version_doc.format(name='brainstorm')

0 commit comments

Comments
 (0)