Skip to content

Commit ee30106

Browse files
authored
Merge pull request #52 from nipreps/tst/cleanup
TEST: Cleanup and start running GitHub actions
2 parents e78aa4b + 1f62d4f commit ee30106

File tree

8 files changed

+90
-35
lines changed

8 files changed

+90
-35
lines changed

Diff for: .github/workflows/pytest.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Pytest
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
tags: [ '*' ]
7+
pull_request:
8+
branches: [ master, 'maint/*' ]
9+
10+
jobs:
11+
build:
12+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: [3.7, 3.8, 3.9]
17+
18+
steps:
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- name: Install nibabies
27+
run: |
28+
python -m venv /tmp/venv
29+
source /tmp/venv/bin/activate
30+
python -m pip install -U pip
31+
python -m pip install --use-feature=in-tree-build ".[test]"
32+
- name: Run Pytest
33+
run: |
34+
source /tmp/venv/bin/activate
35+
pytest -sv --doctest-modules --cov nibabies --cov-report xml nibabies
36+
- name: Submit coverage
37+
run: |
38+
# Pin codecov version to reduce scope for malicious updates
39+
python -m pip install "codecov==2.1.11"
40+
python -m codecov --file coverage.xml

Diff for: nibabies/__init__.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
21
from ._version import get_versions
32
__version__ = get_versions()['version']
43
del get_versions
4+
5+
# Silence PyBIDS warning for extension entity behavior
6+
# Can be removed once minimum PyBIDS dependency hits 0.14
7+
try:
8+
import bids
9+
bids.config.set_option('extension_initial_dot', True)
10+
except (ImportError, ValueError):
11+
pass
12+
else:
13+
del bids

Diff for: nibabies/interfaces/conftest.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""py.test configuration"""
2+
from pathlib import Path
3+
import pytest
4+
from tempfile import TemporaryDirectory
5+
6+
7+
FILES = (
8+
'functional.nii',
9+
'anatomical.nii',
10+
'epi.nii',
11+
'T1w.nii',
12+
'func_to_struct.mat',
13+
'sub-01_run-01_echo-1_bold.nii.gz',
14+
'sub-01_run-01_echo-2_bold.nii.gz',
15+
'sub-01_run-01_echo-3_bold.nii.gz',
16+
)
17+
18+
19+
@pytest.fixture(scope="package")
20+
def data_dir():
21+
with TemporaryDirectory() as tmpdir:
22+
tmp_path = Path(tmpdir)
23+
for fname in FILES:
24+
Path.touch(tmp_path / fname)
25+
yield tmp_path
26+
27+
28+
@pytest.fixture(autouse=True)
29+
def set_namespace(doctest_namespace, data_dir):
30+
doctest_namespace["data_dir"] = data_dir

Diff for: nibabies/interfaces/multiecho.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ class T2SMap(CommandLine):
6363
6464
Example
6565
=======
66-
>>> from fmriprep.interfaces import multiecho
66+
>>> from nibabies.interfaces import multiecho
6767
>>> t2smap = multiecho.T2SMap()
68-
>>> t2smap.inputs.in_files = ['sub-01_run-01_echo-1_bold.nii.gz', \
69-
'sub-01_run-01_echo-2_bold.nii.gz', \
70-
'sub-01_run-01_echo-3_bold.nii.gz']
68+
>>> t2smap.inputs.in_files = [
69+
... data_dir / 'sub-01_run-01_echo-1_bold.nii.gz',
70+
... data_dir / 'sub-01_run-01_echo-2_bold.nii.gz',
71+
... data_dir / 'sub-01_run-01_echo-3_bold.nii.gz']
7172
>>> t2smap.inputs.echo_times = [0.013, 0.027, 0.043]
72-
>>> t2smap.cmdline # doctest: +ELLIPSIS
73-
't2smap -d sub-01_run-01_echo-1_bold.nii.gz sub-01_run-01_echo-2_bold.nii.gz \
74-
sub-01_run-01_echo-3_bold.nii.gz -e 13.0 27.0 43.0 --fittype curvefit'
73+
>>> t2smap.cmdline # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
74+
't2smap -d .../sub-01_run-01_echo-1_bold.nii.gz \
75+
.../sub-01_run-01_echo-2_bold.nii.gz \
76+
.../sub-01_run-01_echo-3_bold.nii.gz -e 13.0 27.0 43.0 --fittype curvefit'
7577
"""
7678
_cmd = 't2smap'
7779
input_spec = T2SMapInputSpec

Diff for: nibabies/reports/core.py

-23
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,6 @@ def run_reports(
3636
):
3737
"""
3838
Run the reports.
39-
40-
.. testsetup::
41-
42-
>>> cwd = os.getcwd()
43-
>>> os.chdir(tmpdir)
44-
45-
>>> from pkg_resources import resource_filename
46-
>>> from shutil import copytree
47-
>>> test_data_path = resource_filename('fmriprep', 'data/tests/work')
48-
>>> testdir = Path(tmpdir)
49-
>>> data_dir = copytree(test_data_path, str(testdir / 'work'))
50-
>>> (testdir / 'fmriprep').mkdir(parents=True, exist_ok=True)
51-
52-
.. doctest::
53-
54-
>>> run_reports(testdir / 'out', '01', 'madeoutuuid', packagename='fmriprep',
55-
... reportlets_dir=testdir / 'work' / 'reportlets' / 'fmriprep')
56-
0
57-
58-
.. testcleanup::
59-
60-
>>> os.chdir(cwd)
61-
6239
"""
6340
return Report(
6441
out_dir,

Diff for: nibabies/utils/bids.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ def extract_entities(file_list):
8383
{'subject': '01', 'suffix': 'T1w', 'datatype': 'anat', 'extension': '.nii.gz'}
8484
>>> extract_entities(['sub-01/anat/sub-01_run-1_T1w.nii.gz',
8585
... 'sub-01/anat/sub-01_run-2_T1w.nii.gz'])
86-
{'subject': '01', 'run': [1, 2], 'suffix': 'T1w', 'datatype': 'anat',
87-
'extension': '.nii.gz'}
86+
{'subject': '01', 'run': [1, 2], 'suffix': 'T1w', 'datatype': 'anat', 'extension': '.nii.gz'}
8887
"""
8988
from collections import defaultdict
9089
from bids.layout import parse_file_entities

Diff for: nibabies/workflows/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ def init_single_subject_wf(subject_id):
382382
fmap_estimators = None
383383
if "fieldmap" not in config.workflow.ignore:
384384
from sdcflows.utils.wrangler import find_estimators
385-
from sdcflows.workflows.base import init_fmap_preproc_wf
386385

387386
# SDC Step 1: Run basic heuristics to identify available data for fieldmap estimation
388387
# For now, no fmapless

Diff for: nibabies/workflows/bold/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False):
449449
# for meepi, iterate over all meepi echos to boldbuffer
450450
boldbuffer.iterables = ('bold_file', bold_file)
451451

452-
453452
# MULTI-ECHO EPI DATA #############################################
454453
if multiecho: # instantiate relevant interfaces, imports
455454
from niworkflows.func.util import init_skullstrip_bold_wf

0 commit comments

Comments
 (0)