Skip to content

Commit 284458d

Browse files
committed
added in example specs from mriqc and reworked test_package_complete test
1 parent cc7a270 commit 284458d

File tree

65 files changed

+3051
-572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3051
-572
lines changed

conftest.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ def gen_test_conftest():
1717
return PKG_DIR / "scripts" / "pkg_gen" / "resources" / "conftest.py"
1818

1919

20-
@pytest.fixture(params=[str(p.stem) for p in EXAMPLE_WORKFLOWS_DIR.glob("*.yaml")])
21-
def workflow_spec_file(request):
22-
return (EXAMPLE_WORKFLOWS_DIR / request.param).with_suffix(".yaml")
23-
24-
2520
@pytest.fixture
2621
def work_dir():
2722
work_dir = tempfile.mkdtemp()

example-specs/workflow/mriqc/interfaces/add_provenance.yaml

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ inputs:
1515
rename:
1616
# dict[str, str] - fields to rename in the Pydra interface
1717
types:
18-
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
19-
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
20-
# from the nipype interface, but you may want to be more specific, particularly
21-
# for file types, where specifying the format also specifies the file that will be
22-
# passed to the field in the automatically generated unittests.
18+
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
19+
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
20+
# from the nipype interface, but you may want to be more specific, particularly
21+
# for file types, where specifying the format also specifies the file that will be
22+
# passed to the field in the automatically generated unittests.
2323
air_msk: generic/file
2424
# type=file|default=<undefined>: air mask file
2525
in_file: generic/file
@@ -43,39 +43,43 @@ outputs:
4343
# for file types, where specifying the format also specifies the file that will be
4444
# passed to the field in the automatically generated unittests.
4545
callables:
46-
# dict[str, str] - names of methods/callable classes defined in the adjacent `*_callables.py`
47-
# to set to the `callable` attribute of output fields
46+
# dict[str, str] - names of methods/callable classes defined in the adjacent `*_callables.py`
47+
# to set to the `callable` attribute of output fields
4848
out_prov: out_prov_callable
49-
# type=dict:
49+
# type=dict:
5050
templates:
5151
# dict[str, str] - `output_file_template` values to be provided to output fields
5252
requirements:
5353
# dict[str, list[str]] - input fields that are required to be provided for the output field to be present
5454
tests:
55-
- inputs:
56-
# dict[str, str] - values to provide to inputs fields in the task initialisation
57-
# (if not specified, will try to choose a sensible value)
58-
in_file:
59-
# type=file|default=<undefined>: input file
60-
air_msk:
61-
# type=file|default=<undefined>: air mask file
62-
rot_msk:
63-
# type=file|default=<undefined>: rotation mask file
64-
modality:
65-
# type=str|default='': provenance type
66-
imports:
67-
# list[nipype2pydra.task.base.explicitimport] - list import statements required by the test, with each list item
68-
# consisting of 'module', 'name', and optionally 'alias' keys
69-
expected_outputs:
70-
# dict[str, str] - expected values for selected outputs, noting that tests will typically
71-
# be terminated before they complete for time-saving reasons, and therefore
72-
# these values will be ignored, when running in CI
73-
timeout: 10
74-
# int - the value to set for the timeout in the generated test,
75-
# after which the test will be considered to have been initialised
76-
# successfully. Set to 0 to disable the timeout (warning, this could
77-
# lead to the unittests taking a very long time to complete)
78-
xfail: true
79-
# bool - whether the unittest is expected to fail or not. Set to false
80-
# when you are satisfied with the edits you have made to this file
55+
- inputs:
56+
# dict[str, str] - values to provide to inputs fields in the task initialisation
57+
# (if not specified, will try to choose a sensible value)
58+
in_file:
59+
# type=file|default=<undefined>: input file
60+
air_msk:
61+
# type=file|default=<undefined>: air mask file
62+
rot_msk:
63+
# type=file|default=<undefined>: rotation mask file
64+
modality:
65+
# type=str|default='': provenance type
66+
imports:
67+
# list[nipype2pydra.task.base.explicitimport] - list import statements required by the test, with each list item
68+
# consisting of 'module', 'name', and optionally 'alias' keys
69+
expected_outputs:
70+
# dict[str, str] - expected values for selected outputs, noting that tests will typically
71+
# be terminated before they complete for time-saving reasons, and therefore
72+
# these values will be ignored, when running in CI
73+
timeout: 10
74+
# int - the value to set for the timeout in the generated test,
75+
# after which the test will be considered to have been initialised
76+
# successfully. Set to 0 to disable the timeout (warning, this could
77+
# lead to the unittests taking a very long time to complete)
78+
xfail: true
79+
# bool - whether the unittest is expected to fail or not. Set to false
80+
# when you are satisfied with the edits you have made to this file
8181
doctests: []
82+
find_replace:
83+
- ["config.environment.version", "'<version-not-captured>'"]
84+
- ["config.execution.debug", "False"]
85+
- ["config.workflow.fd_thres,", "0.2, # <configuration>.fd_thres"]

example-specs/workflow/mriqc/interfaces/conform_image.yaml

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#
66
# Docs
77
# ----
8-
#
8+
#
99
# Conforms an input image.
10-
#
10+
#
1111
# List of nifti datatypes:
12-
#
12+
#
1313
# .. note: Original Analyze 7.5 types
14-
#
14+
#
1515
# DT_NONE 0
1616
# DT_UNKNOWN 0 / what it says, dude /
1717
# DT_BINARY 1 / binary (1 bit/voxel) /
@@ -23,19 +23,19 @@
2323
# DT_DOUBLE 64 / double (64 bits/voxel) /
2424
# DT_RGB 128 / RGB triple (24 bits/voxel) /
2525
# DT_ALL 255 / not very useful (?) /
26-
#
26+
#
2727
# .. note: Added names for the same data types
28-
#
28+
#
2929
# DT_UINT8 2
3030
# DT_INT16 4
3131
# DT_INT32 8
3232
# DT_FLOAT32 16
3333
# DT_COMPLEX64 32
3434
# DT_FLOAT64 64
3535
# DT_RGB24 128
36-
#
36+
#
3737
# .. note: New codes for NIfTI
38-
#
38+
#
3939
# DT_INT8 256 / signed char (8 bits) /
4040
# DT_UINT16 512 / unsigned short (16 bits) /
4141
# DT_UINT32 768 / unsigned int (32 bits) /
@@ -59,8 +59,8 @@
5959
# NIFTI_TYPE_FLOAT128 1536 /! 128 bit float = long double. /
6060
# NIFTI_TYPE_COMPLEX128 1792 /! 128 bit complex = 2 64 bit floats. /
6161
# NIFTI_TYPE_COMPLEX256 2048 /! 256 bit complex = 2 128 bit floats /
62-
#
63-
#
62+
#
63+
#
6464
task_name: ConformImage
6565
nipype_name: ConformImage
6666
nipype_module: mriqc.interfaces.common.conform_image
@@ -70,11 +70,11 @@ inputs:
7070
rename:
7171
# dict[str, str] - fields to rename in the Pydra interface
7272
types:
73-
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
74-
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
75-
# from the nipype interface, but you may want to be more specific, particularly
76-
# for file types, where specifying the format also specifies the file that will be
77-
# passed to the field in the automatically generated unittests.
73+
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
74+
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
75+
# from the nipype interface, but you may want to be more specific, particularly
76+
# for file types, where specifying the format also specifies the file that will be
77+
# passed to the field in the automatically generated unittests.
7878
in_file: generic/file
7979
# type=file|default=<undefined>: input image
8080
callable_defaults:
@@ -88,11 +88,11 @@ outputs:
8888
rename:
8989
# dict[str, str] - fields to rename in the Pydra interface
9090
types:
91-
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
92-
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
93-
# from the nipype interface, but you may want to be more specific, particularly
94-
# for file types, where specifying the format also specifies the file that will be
95-
# passed to the field in the automatically generated unittests.
91+
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
92+
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
93+
# from the nipype interface, but you may want to be more specific, particularly
94+
# for file types, where specifying the format also specifies the file that will be
95+
# passed to the field in the automatically generated unittests.
9696
out_file: generic/file
9797
# type=file: output conformed file
9898
callables:
@@ -103,28 +103,34 @@ outputs:
103103
requirements:
104104
# dict[str, list[str]] - input fields that are required to be provided for the output field to be present
105105
tests:
106-
- inputs:
107-
# dict[str, str] - values to provide to inputs fields in the task initialisation
108-
# (if not specified, will try to choose a sensible value)
109-
in_file:
110-
# type=file|default=<undefined>: input image
111-
check_ras:
112-
# type=bool|default=True: check that orientation is RAS
113-
check_dtype:
114-
# type=bool|default=True: check data type
115-
imports:
116-
# list[nipype2pydra.task.base.explicitimport] - list import statements required by the test, with each list item
117-
# consisting of 'module', 'name', and optionally 'alias' keys
118-
expected_outputs:
119-
# dict[str, str] - expected values for selected outputs, noting that tests will typically
120-
# be terminated before they complete for time-saving reasons, and therefore
121-
# these values will be ignored, when running in CI
122-
timeout: 10
123-
# int - the value to set for the timeout in the generated test,
124-
# after which the test will be considered to have been initialised
125-
# successfully. Set to 0 to disable the timeout (warning, this could
126-
# lead to the unittests taking a very long time to complete)
127-
xfail: true
128-
# bool - whether the unittest is expected to fail or not. Set to false
129-
# when you are satisfied with the edits you have made to this file
106+
- inputs:
107+
# dict[str, str] - values to provide to inputs fields in the task initialisation
108+
# (if not specified, will try to choose a sensible value)
109+
in_file:
110+
# type=file|default=<undefined>: input image
111+
check_ras:
112+
# type=bool|default=True: check that orientation is RAS
113+
check_dtype:
114+
# type=bool|default=True: check data type
115+
imports:
116+
# list[nipype2pydra.task.base.explicitimport] - list import statements required by the test, with each list item
117+
# consisting of 'module', 'name', and optionally 'alias' keys
118+
expected_outputs:
119+
# dict[str, str] - expected values for selected outputs, noting that tests will typically
120+
# be terminated before they complete for time-saving reasons, and therefore
121+
# these values will be ignored, when running in CI
122+
timeout: 10
123+
# int - the value to set for the timeout in the generated test,
124+
# after which the test will be considered to have been initialised
125+
# successfully. Set to 0 to disable the timeout (warning, this could
126+
# lead to the unittests taking a very long time to complete)
127+
xfail: true
128+
# bool - whether the unittest is expected to fail or not. Set to false
129+
# when you are satisfied with the edits you have made to this file
130130
doctests: []
131+
find_replace:
132+
- [config\.loggers\.interface, "logger"]
133+
- [
134+
messages\.SUSPICIOUS_DATA_TYPE,
135+
'"Input image {in_file} has a suspicious data type: ''{dtype}''"',
136+
]

example-specs/workflow/mriqc/interfaces/datalad_identity_interface_callables.py

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# This file is used to manually specify the semi-automatic conversion of
2+
# 'mriqc.interfaces.DerivativesDataSink' from Nipype to Pydra.
3+
#
4+
# Please fill-in/edit the fields below where appropriate
5+
#
6+
# Docs
7+
# ----
8+
#
9+
task_name: DerivativesDataSink
10+
nipype_name: DerivativesDataSink
11+
nipype_module: mriqc.interfaces
12+
inputs:
13+
omit:
14+
# list[str] - fields to omit from the Pydra interface
15+
rename:
16+
# dict[str, str] - fields to rename in the Pydra interface
17+
types:
18+
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
19+
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
20+
# from the nipype interface, but you may want to be more specific, particularly
21+
# for file types, where specifying the format also specifies the file that will be
22+
# passed to the field in the automatically generated unittests.
23+
base_directory: generic/directory
24+
# type=directory|default='': Path to the base directory for storing data.
25+
in_file: generic/file+list-of
26+
# type=inputmultiobject|default=[]: the object to be saved
27+
source_file: generic/file+list-of
28+
# type=inputmultiobject|default=[]: the source file(s) to extract entities from
29+
callable_defaults:
30+
# dict[str, str] - names of methods/callable classes defined in the adjacent `*_callables.py`
31+
# to set as the `default` method of input fields
32+
metadata:
33+
# dict[str, dict[str, any]] - additional metadata to set on any of the input fields (e.g. out_file: position: 1)
34+
outputs:
35+
omit:
36+
# list[str] - fields to omit from the Pydra interface
37+
rename:
38+
# dict[str, str] - fields to rename in the Pydra interface
39+
types:
40+
# dict[str, type] - override inferred types (use "mime-like" string for file-format types,
41+
# e.g. 'medimage/nifti-gz'). For most fields the type will be correctly inferred
42+
# from the nipype interface, but you may want to be more specific, particularly
43+
# for file types, where specifying the format also specifies the file that will be
44+
# passed to the field in the automatically generated unittests.
45+
out_file: generic/file+list-of
46+
# type=outputmultiobject:
47+
out_meta: generic/file+list-of
48+
# type=outputmultiobject:
49+
callables:
50+
# dict[str, str] - names of methods/callable classes defined in the adjacent `*_callables.py`
51+
# to set to the `callable` attribute of output fields
52+
templates:
53+
# dict[str, str] - `output_file_template` values to be provided to output fields
54+
requirements:
55+
# dict[str, list[str]] - input fields that are required to be provided for the output field to be present
56+
tests:
57+
- inputs:
58+
# dict[str, str] - values to provide to inputs fields in the task initialisation
59+
# (if not specified, will try to choose a sensible value)
60+
base_directory:
61+
# type=directory|default='': Path to the base directory for storing data.
62+
check_hdr:
63+
# type=bool|default=True: fix headers of NIfTI outputs
64+
compress:
65+
# type=inputmultiobject|default=[]: whether ``in_file`` should be compressed (True), uncompressed (False) or left unmodified (None, default).
66+
data_dtype:
67+
# type=str|default='': NumPy datatype to coerce NIfTI data to, or `source` tomatch the input file dtype
68+
dismiss_entities:
69+
# type=inputmultiobject|default=[]: a list entities that will not be propagated from the source file
70+
in_file:
71+
# type=inputmultiobject|default=[]: the object to be saved
72+
meta_dict:
73+
# type=dict|default={}: an input dictionary containing metadata
74+
source_file:
75+
# type=inputmultiobject|default=[]: the source file(s) to extract entities from
76+
imports:
77+
# list[nipype2pydra.task.base.explicitimport] - list import statements required by the test, with each list item
78+
# consisting of 'module', 'name', and optionally 'alias' keys
79+
expected_outputs:
80+
# dict[str, str] - expected values for selected outputs, noting that tests will typically
81+
# be terminated before they complete for time-saving reasons, and therefore
82+
# these values will be ignored, when running in CI
83+
timeout: 10
84+
# int - the value to set for the timeout in the generated test,
85+
# after which the test will be considered to have been initialised
86+
# successfully. Set to 0 to disable the timeout (warning, this could
87+
# lead to the unittests taking a very long time to complete)
88+
xfail: true
89+
# bool - whether the unittest is expected to fail or not. Set to false
90+
# when you are satisfied with the edits you have made to this file
91+
doctests: []
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Module to put any functions that are referred to in the "callables" section of DerivativesDataSink.yaml"""
2+
3+
4+
def compression_callable(output_dir, inputs, stdout, stderr):
5+
outputs = _list_outputs(
6+
output_dir=output_dir, inputs=inputs, stdout=stdout, stderr=stderr
7+
)
8+
return outputs["compression"]
9+
10+
11+
def fixed_hdr_callable(output_dir, inputs, stdout, stderr):
12+
outputs = _list_outputs(
13+
output_dir=output_dir, inputs=inputs, stdout=stdout, stderr=stderr
14+
)
15+
return outputs["fixed_hdr"]
16+
17+
18+
def out_file_callable(output_dir, inputs, stdout, stderr):
19+
outputs = _list_outputs(
20+
output_dir=output_dir, inputs=inputs, stdout=stdout, stderr=stderr
21+
)
22+
return outputs["out_file"]
23+
24+
25+
def out_meta_callable(output_dir, inputs, stdout, stderr):
26+
outputs = _list_outputs(
27+
output_dir=output_dir, inputs=inputs, stdout=stdout, stderr=stderr
28+
)
29+
return outputs["out_meta"]
30+
31+
32+
# Original source at L568 of <nipype-install>/interfaces/base/core.py
33+
def _list_outputs(inputs=None, stdout=None, stderr=None, output_dir=None):
34+
return _results

0 commit comments

Comments
 (0)