Skip to content

Commit 552bac5

Browse files
authored
Merge pull request #19 from effigies/test/data
TEST: Get data files for Node/Workflow tests
2 parents e01f7e4 + 39b9563 commit 552bac5

File tree

5 files changed

+49
-46
lines changed

5 files changed

+49
-46
lines changed

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@ python:
66
- 3.6
77
- 3.7
88

9+
env:
10+
- PYDRA_TEST_DATA=/tmp/pydra_test_data
11+
12+
before_install:
13+
- travis_retry bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh);
14+
- travis_retry sudo apt-get update
15+
- travis_retry sudo apt-get install fsl git-annex-standalone datalad
16+
- source /etc/fsl/fsl.sh
17+
- travis_retry pip install --upgrade pip setuptools wheel
18+
919
install:
10-
- pip install --upgrade pip setuptools wheel
1120
- pip install ".[all]"
1221

22+
before_script:
23+
- bash tools/get_test_data.sh
24+
1325
script:
1426
- py.test -vs -n auto --cov pydra --cov-config .coveragerc --cov-report xml:cov.xml --doctest-modules pydra
1527

pydra/__about__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363

6464
EXTRA_REQUIRES = {
6565
'tests': TESTS_REQUIRES,
66+
'dev': TESTS_REQUIRES + ['yapf>=0.22'],
6667
'plugins': ['dask', 'distributed'],
6768
}
6869

pydra/engine/tests/test_newnode.py renamed to pydra/engine/tests/test_node.py

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
import sys
2+
import os
3+
import time
4+
import numpy as np
5+
from pathlib import Path
6+
17
from nipype.utils.filemanip import save_json, makedirs, to_str
28
from nipype.interfaces import fsl
39

410
from ..node import Node, Workflow
511
from ..auxiliary import FunctionInterface, CurrentInterface
612
from ..submitter import Submitter
713

8-
import sys, time, os
9-
import numpy as np
10-
import pytest, pdb
14+
import pytest
15+
import pdb
16+
17+
TEST_DATA_DIR = Path(os.getenv('PYDRA_TEST_DATA', '/nonexistent/path'))
18+
DS114_DIR = TEST_DATA_DIR / 'ds000114'
1119

1220
python35_only = pytest.mark.skipif(sys.version_info < (3, 5), reason="requires Python>3.4")
1321

@@ -1441,8 +1449,7 @@ def test_workflow_16a(plugin, change_dir):
14411449
# testing CurrentInterface that is a temporary wrapper for current interfaces
14421450

14431451

1444-
@pytest.mark.skipif(
1445-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1452+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
14461453
@pytest.mark.parametrize("plugin", Plugins)
14471454
@python35_only
14481455
def test_current_node_1(change_dir, plugin):
@@ -1451,10 +1458,7 @@ def test_current_node_1(change_dir, plugin):
14511458

14521459
nn = Node(
14531460
name="NA",
1454-
inputs={
1455-
"in_file":
1456-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1457-
},
1461+
inputs={"in_file": str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")},
14581462
interface=interf_bet,
14591463
workingdir="test_cnd1_{}".format(plugin),
14601464
output_names=["out_file"])
@@ -1466,17 +1470,16 @@ def test_current_node_1(change_dir, plugin):
14661470
assert "out_file" in nn.output.keys()
14671471

14681472

1469-
@pytest.mark.skipif(
1470-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1473+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
14711474
@pytest.mark.parametrize("plugin", Plugins)
14721475
@python35_only
14731476
def test_current_node_2(change_dir, plugin):
14741477
"""Node with a current interface and mapper"""
14751478
interf_bet = CurrentInterface(interface=fsl.BET(), name="fsl_interface")
14761479

14771480
in_file_l = [
1478-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz",
1479-
"/Users/dorota/nipype_workshop/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1481+
str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"),
1482+
str(DS114_DIR / "sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
14801483
]
14811484
nn = Node(
14821485
name="NA",
@@ -1496,8 +1499,7 @@ def test_current_node_2(change_dir, plugin):
14961499
assert "NA.in_file:1" in nn.output["out_file"].keys()
14971500

14981501

1499-
@pytest.mark.skipif(
1500-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1502+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
15011503
@pytest.mark.parametrize("plugin", Plugins)
15021504
@python35_only
15031505
def test_current_wf_1(change_dir, plugin):
@@ -1506,10 +1508,7 @@ def test_current_wf_1(change_dir, plugin):
15061508

15071509
nn = Node(
15081510
name="fsl",
1509-
inputs={
1510-
"in_file":
1511-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1512-
},
1511+
inputs={"in_file": str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")},
15131512
interface=interf_bet,
15141513
workingdir="nn",
15151514
output_names=["out_file"],
@@ -1529,8 +1528,7 @@ def test_current_wf_1(change_dir, plugin):
15291528
assert "fsl_out" in wf.output.keys()
15301529

15311530

1532-
@pytest.mark.skipif(
1533-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1531+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
15341532
@pytest.mark.parametrize("plugin", Plugins)
15351533
@python35_only
15361534
def test_current_wf_1a(change_dir, plugin):
@@ -1539,10 +1537,7 @@ def test_current_wf_1a(change_dir, plugin):
15391537

15401538
nn = Node(
15411539
name="fsl",
1542-
inputs={
1543-
"in_file":
1544-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1545-
},
1540+
inputs={"in_file": str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")},
15461541
interface=interf_bet,
15471542
workingdir="nn",
15481543
output_names=["out_file"],
@@ -1562,8 +1557,7 @@ def test_current_wf_1a(change_dir, plugin):
15621557
assert "fsl_out" in wf.output.keys()
15631558

15641559

1565-
@pytest.mark.skipif(
1566-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1560+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
15671561
@pytest.mark.parametrize("plugin", Plugins)
15681562
@python35_only
15691563
def test_current_wf_1b(change_dir, plugin):
@@ -1581,10 +1575,7 @@ def test_current_wf_1b(change_dir, plugin):
15811575
workingdir="nn",
15821576
output_names=["out_file"],
15831577
write_state=False,
1584-
inputs={
1585-
"in_file":
1586-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1587-
})
1578+
inputs={"in_file": str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")})
15881579

15891580
sub = Submitter(plugin=plugin, runnable=wf)
15901581
sub.run()
@@ -1593,8 +1584,7 @@ def test_current_wf_1b(change_dir, plugin):
15931584
assert "fsl_out" in wf.output.keys()
15941585

15951586

1596-
@pytest.mark.skipif(
1597-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1587+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
15981588
@pytest.mark.parametrize("plugin", Plugins)
15991589
@python35_only
16001590
def test_current_wf_1c(change_dir, plugin):
@@ -1611,10 +1601,7 @@ def test_current_wf_1c(change_dir, plugin):
16111601
workingdir="nn",
16121602
output_names=["out_file"],
16131603
write_state=False,
1614-
inputs={
1615-
"in_file":
1616-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"
1617-
})
1604+
inputs={"in_file": str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz")})
16181605

16191606
sub = Submitter(plugin=plugin, runnable=wf)
16201607
sub.run()
@@ -1623,17 +1610,16 @@ def test_current_wf_1c(change_dir, plugin):
16231610
assert "fsl_out" in wf.output.keys()
16241611

16251612

1626-
@pytest.mark.skipif(
1627-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1613+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
16281614
@pytest.mark.parametrize("plugin", Plugins)
16291615
@python35_only
16301616
def test_current_wf_2(change_dir, plugin):
16311617
"""Wf with a current interface and mapper"""
16321618
interf_bet = CurrentInterface(interface=fsl.BET(), name="fsl_interface")
16331619

16341620
in_file_l = [
1635-
"/Users/dorota/nipype_workshop/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz",
1636-
"/Users/dorota/nipype_workshop/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1621+
str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"),
1622+
str(DS114_DIR / "sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
16371623
]
16381624

16391625
nn = Node(
@@ -1662,17 +1648,16 @@ def test_current_wf_2(change_dir, plugin):
16621648
assert 'cw2.in_file:1' in wf.output["fsl_out"].keys()
16631649

16641650

1665-
@pytest.mark.skipif(
1666-
not os.path.exists("/Users/dorota/nipype_workshop/data/ds000114"), reason="adding data")
1651+
@pytest.mark.skipif(not DS114_DIR.exists(), reason="Missing $PYDRA_TEST_DATA/ds000114")
16671652
@pytest.mark.parametrize("plugin", Plugins)
16681653
@python35_only
16691654
def test_current_wf_2a(change_dir, plugin):
16701655
"""Wf with a current interface and mapper"""
16711656
interf_bet = CurrentInterface(interface=fsl.BET(), name="fsl_interface")
16721657

16731658
in_file_l = [
1674-
"/data/ds000114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz",
1675-
"/data/ds000114/sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz"
1659+
str(DS114_DIR / "sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz"),
1660+
str(DS114_DIR / "sub-02/ses-test/anat/sub-02_ses-test_T1w.nii.gz")
16761661
]
16771662

16781663
nn = Node(
File renamed without changes.

tools/get_test_data.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
mkdir -p $PYDRA_TEST_DATA
4+
datalad install -r -s ///openfmri/ds000114 $PYDRA_TEST_DATA/ds000114
5+
datalad get $PYDRA_TEST_DATA/ds000114/sub-0{1,2}/ses-test/anat/sub-0?_ses-test_T1w.nii.gz

0 commit comments

Comments
 (0)