Skip to content

Commit dbd0376

Browse files
committed
Setting up tests to use development fileformats
1 parent 74ce71b commit dbd0376

File tree

7 files changed

+24
-130
lines changed

7 files changed

+24
-130
lines changed

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ jobs:
3939
pip install ".[test]"
4040
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
4141
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
42-
- name: Install development Pydra
43-
run: pip install --no-deps git+https://github.com/nipype/pydra.git@new-syntax
42+
- name: Install development Pydra and fileformats-medimage
43+
run: |
44+
pip install --no-deps git+https://github.com/nipype/pydra.git@new-syntax
45+
pip install --no-deps git+https://github.com/arcanaframework/fileformats-medimage.git@pydra-syntax-changes
4446
- name: Test with pytest
4547
run: |
46-
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \
47-
--cov pydra.tasks.$SUBPACKAGE --cov-report xml
48+
pytest -sv --cov pydra.tasks.$SUBPACKAGE --cov-report xml
4849
- uses: codecov/codecov-action@v1
4950
if: ${{ always() }}
5051

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import os
12
from pydra.tasks.dcm2niix.utils import Dcm2Niix
23
from fileformats.medimage import DicomDir
34

45

56
def test_dcm2niix():
67
task = Dcm2Niix()
7-
task.inputs.in_dir = DicomDir.mock("test-data/test_dicoms")
8-
task.inputs.out_dir = "test-data"
9-
task.inputs.compress = "y"
8+
task.in_dir = DicomDir.mock("test-data/test_dicoms")
9+
task.out_dir = "test-data"
10+
task.compress = "y"
1011
assert (
11-
task.cmdline == "dcm2niix -o test-data -f out_file -z y test-data/test_dicoms"
12+
task.cmdline
13+
== f"dcm2niix -b y -z y -f out_file -o test-data {os.getcwd()}/test-data/test_dicoms"
1214
)

pydra/tasks/dcm2niix/utils.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import attrs
21
from pathlib import Path
32
import typing as ty
43
from pydra.engine.specs import ShellDef, ShellOutputs
5-
from fileformats.generic import File, Directory, FileSet
64
from fileformats.application import Json
7-
from fileformats.medimage import Nifti1, NiftiGz, Bvec, Bval
5+
from fileformats.medimage import DicomDir, Nifti1, NiftiGz, Bvec, Bval
86
from pydra.design import shell
97

108

11-
FS = ty.TypeVar("FS", bound=FileSet)
9+
FS = ty.TypeVar("FS", bound=Nifti1 | NiftiGz | Json | Bval | Bvec)
1210

1311

1412
def get_out_file(
@@ -105,16 +103,16 @@ class Dcm2Niix(ShellDef["Dcm2Niix.Outputs"]):
105103
Example
106104
-------
107105
>>> task = Dcm2Niix()
108-
>>> task.inputs.in_dir = "test-data/test_dicoms"
109-
>>> task.inputs.out_dir = "test-data"
110-
>>> task.inputs.compress = "y"
106+
>>> task.in_dir = "test-data/test_dicoms"
107+
>>> task.out_dir = "test-data"
108+
>>> task.compress = "y"
111109
>>> task.cmdline
112-
'dcm2niix -o test-data -f out_file -z y test-data/test_dicoms'
110+
'dcm2niix -b y -z y -f out_file -o test-data test-data/test_dicoms'
113111
"""
114112

115113
executable = "dcm2niix"
116114

117-
in_dir: Directory = shell.arg(
115+
in_dir: DicomDir = shell.arg(
118116
argstr="'{in_dir}'",
119117
position=-1,
120118
help=("The directory containing the DICOMs to be converted"),
@@ -124,7 +122,7 @@ class Dcm2Niix(ShellDef["Dcm2Niix.Outputs"]):
124122
argstr="-o '{out_dir}'",
125123
help="output directory",
126124
)
127-
filename: str = shell.arg(
125+
filename: str | None = shell.arg(
128126
argstr="-f '{filename}'",
129127
help="The output name for the file",
130128
default="out_file",
@@ -320,7 +318,7 @@ class Outputs(ShellOutputs):
320318
# requires=[("bids", "y")], # FIXME: should be either 'y' or 'o'
321319
callable=dcm2niix_out_bvec,
322320
)
323-
out_files: list[File] = shell.out(
321+
out_files: list[Nifti1 | NiftiGz | Json | Bval | Bvec] = shell.out(
324322
help=(
325323
"all output files in a list, including files disambiguated "
326324
"by their suffixes (e.g. echoes, phase-maps, etc... see "

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "pydra-dcm2niix"
77
description = "pydra-dcm2niix contains Pydra task specifications for the Dcm2niix converter"
88
readme = "README.md"
99
requires-python = ">=3.11"
10-
dependencies = ["pydra >=0.25"]
10+
dependencies = ["fileformats>=0.15a2", "pydra >=0.25"]
1111
license = { file = "LICENSE" }
1212
authors = [{ name = "Thomas G. Close", email = "[email protected]" }]
1313
maintainers = [{ name = "Thomas G. Close", email = "[email protected]" }]
@@ -32,7 +32,7 @@ dev = [
3232
"click >=8.1.3",
3333
"tqdm",
3434
"attrs >=23.1.0",
35-
"fileformats-extras >= 0.12.1",
35+
"fileformats-extras >= 0.15a2",
3636
]
3737
doc = [
3838
"packaging",
@@ -49,7 +49,6 @@ test = [
4949
"pytest-xdist",
5050
"pytest-rerunfailures",
5151
"codecov",
52-
"fileformats-medimage_dcm2niix-extras",
5352
]
5453

5554
[tool.hatch.version]

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = -vv

setup.cfg

Lines changed: 0 additions & 82 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)