Skip to content

Commit 9d0cd14

Browse files
authored
Merge pull request #20 from nipype/precommit
MNT: Pre-commit configuration + restyling
2 parents 7565003 + 9ff4241 commit 9d0cd14

Some content is hidden

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

76 files changed

+308
-399
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,3 @@ dmypy.json
130130

131131
# Pycharm
132132
.idea
133-

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.0.1
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/psf/black
12+
rev: 21.8b0
13+
hooks:
14+
- id: black
15+
exclude: (_version\.py|versioneer\.py)$

README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,55 @@ pip install -e /path/to/pydra-fsl/[dev]
2323
`FSLConverter` class (from `tools/converter.py`) requires three parts of information:
2424

2525
- Nipype spec: converter loads nipype interface and reads `_cmd`, `input_spec` and `output_spec`
26-
- yml file with additional spec: `specs/fsl_{module_name}_params.yml` contains additional spec that are written based
26+
- yml file with additional spec: `specs/fsl_{module_name}_params.yml` contains additional spec that are written based
2727
on additional functions from nipype (including `list_outputs`), each interface can have the following fields:
28-
- inputs_metadata: additional metadata for fields from input_spec
29-
(it will be included in `metadata` in pydra spec),
30-
e.g., used in `specs/fsl_preprocess_params.yml` for `FAST` to set default value for `number_classes`
28+
- inputs_metadata: additional metadata for fields from input_spec
29+
(it will be included in `metadata` in pydra spec),
30+
e.g., used in `specs/fsl_preprocess_params.yml` for `FAST` to set default value for `number_classes`
3131
(it's not part of nipype's spec, but it's set in `list_output`)
3232

33-
- output_requirements: providing required fields for the output to be created,
34-
taken from `list_output` structure;
33+
- output_requirements: providing required fields for the output to be created,
34+
taken from `list_output` structure;
3535
it's a part of the `requires` field in metadata in pydra spec
36-
37-
- output_templates: providing template to create the output file name,
38-
taken from `list_output` structure;
36+
37+
- output_templates: providing template to create the output file name,
38+
taken from `list_output` structure;
3939
it is set as `output_file_template` in metadata
40-
40+
4141
- output_callables: providing function name that should be used to gather output,
4242
based on the `list_output` structure and used only for `FAST`;
4343
it is set as `callable` in metadata
44-
45-
- tests_inputs, tests_outputs: specification for tests,
46-
the fields should have the same length and each element should contain
44+
45+
- tests_inputs, tests_outputs: specification for tests,
46+
the fields should have the same length and each element should contain
4747
the input fields values and list of the expected output fields names
48-
48+
4949
- doctests: specification for doctest,
50-
should include values for input fields and the expected `cmdline`
50+
should include values for input fields and the expected `cmdline`
5151

52-
- python file with functions used as callables to gather the outputs:
52+
- python file with functions used as callables to gather the outputs:
5353
`specs/callables.py` should contain all the functions from `output_callables`;
5454
the source code of the functions is read and written again in the pydra interface file
5555

5656

5757
### How to use the convert
5858

5959
The converter can be used by running:
60-
60+
6161
python tools/converter.py --interface_name <name of teh interface> --module_name <module_name>
6262

6363
The pydra task will be created and saved in `pydra/tasks/fsl/{module_name}/{interface_name}.py`.
6464
Note, that the spec file has to be present for the specific module name in order to run the converter.
6565
If no `interface_name` is provided, the default value `all` will be used
6666
and the converter will be run for all interfaces from the spec file.
6767

68-
Tests are written based on the fields from the yml file:
68+
Tests are written based on the fields from the yml file:
6969
`tests_inputs` and `tests_outputs` (the lengths should be the same).
7070
One test, `test_specs_*` checks only the correctness of the spec based
7171
on the `test_inputs/outputs` pairs, i.e. predicts which output fields
7272
should be created based on the list of the input fields.
73-
The second test, `test_run_*` should run the interfaces
74-
(TODO: this is temporary, should be removed from the final repo).
73+
The second test, `test_run_*` should run the interfaces
74+
(TODO: this is temporary, should be removed from the final repo).
7575
Tests can be run using `pytest`:
7676

7777
pytest -vs pydra/tasks/fsl/{module_name}/tests
78-

pydra/tasks/fsl/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"""
88

99
from ._version import get_versions
10+
1011
__version__ = get_versions()['version']
1112
del get_versions

pydra/tasks/fsl/conftest.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
import shutil
33
from tempfile import mkdtemp
44
import pytest
5-
#import numpy
5+
6+
# import numpy
67
import py.path as pp
78

8-
NIPYPE_DATADIR = os.path.realpath(
9-
os.path.join(os.path.dirname(__file__), "tests/data")
10-
)
9+
NIPYPE_DATADIR = os.path.realpath(os.path.join(os.path.dirname(__file__), "tests/data"))
1110
temp_folder = mkdtemp()
1211
data_dir = os.path.join(temp_folder, "data")
1312
shutil.copytree(NIPYPE_DATADIR, data_dir)
1413

1514

1615
@pytest.fixture(autouse=True)
1716
def add_np(doctest_namespace):
18-
# doctest_namespace["np"] = numpy
17+
# doctest_namespace["np"] = numpy
1918
doctest_namespace["os"] = os
2019
doctest_namespace["pytest"] = pytest
2120
doctest_namespace["datadir"] = data_dir

pydra/tasks/fsl/preprocess/applywarp.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@
115115
},
116116
),
117117
]
118-
ApplyWarp_input_spec = specs.SpecInfo(
119-
name="Input", fields=input_fields, bases=(specs.ShellSpec,)
120-
)
118+
ApplyWarp_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
121119

122120
output_fields = []
123121
ApplyWarp_output_spec = specs.SpecInfo(

pydra/tasks/fsl/preprocess/bet.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@
183183
},
184184
),
185185
]
186-
BET_input_spec = specs.SpecInfo(
187-
name="Input", fields=input_fields, bases=(specs.ShellSpec,)
188-
)
186+
BET_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
189187

190188
output_fields = [
191189
(
@@ -288,9 +286,7 @@
288286
},
289287
),
290288
]
291-
BET_output_spec = specs.SpecInfo(
292-
name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
293-
)
289+
BET_output_spec = specs.SpecInfo(name="Output", fields=output_fields, bases=(specs.ShellOutSpec,))
294290

295291

296292
class BET(ShellCommandTask):

pydra/tasks/fsl/preprocess/fast.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ def FAST_output_nclass(field, in_files, nclasses, out_basename):
228228
{"help_string": "outputs individual probability maps", "argstr": "-p"},
229229
),
230230
]
231-
FAST_input_spec = specs.SpecInfo(
232-
name="Input", fields=input_fields, bases=(specs.ShellSpec,)
233-
)
231+
FAST_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
234232

235233
output_fields = [
236234
(
@@ -263,9 +261,7 @@ def FAST_output_nclass(field, in_files, nclasses, out_basename):
263261
{"requires": [("probability_maps", True)], "callable": "FAST_output_nclass"},
264262
),
265263
]
266-
FAST_output_spec = specs.SpecInfo(
267-
name="Output", fields=output_fields, bases=(specs.ShellOutSpec,)
268-
)
264+
FAST_output_spec = specs.SpecInfo(name="Output", fields=output_fields, bases=(specs.ShellOutSpec,))
269265

270266

271267
class FAST(ShellCommandTask):

pydra/tasks/fsl/preprocess/first.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@
8787
},
8888
),
8989
]
90-
FIRST_input_spec = specs.SpecInfo(
91-
name="Input", fields=input_fields, bases=(specs.ShellSpec,)
92-
)
90+
FIRST_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
9391

9492
output_fields = [
9593
(

pydra/tasks/fsl/preprocess/flirt.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,7 @@
334334
{"help_string": "value of bbr slope", "argstr": "-bbrslope {bbrslope}"},
335335
),
336336
]
337-
FLIRT_input_spec = specs.SpecInfo(
338-
name="Input", fields=input_fields, bases=(specs.ShellSpec,)
339-
)
337+
FLIRT_input_spec = specs.SpecInfo(name="Input", fields=input_fields, bases=(specs.ShellSpec,))
340338

341339
output_fields = []
342340
FLIRT_output_spec = specs.SpecInfo(

0 commit comments

Comments
 (0)