Skip to content

debugged unittests #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.11"]
python-version: ["3.8", "3.11"]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.venv
.venv*
/.project
/.pydevproject
*.pyc
Expand Down
23 changes: 23 additions & 0 deletions example-specs/task/ants_n4_bias_field_correction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ tests:
dimension: '3'
input_image:
bspline_fitting_distance: '300'
save_bias: 'False'
copy_header: 'False'
shrink_factor: '3'
n_iterations: '[50,50,30,20]'
imports: &id001
Expand All @@ -186,6 +188,10 @@ tests:
# dict[str, str] - values to provide to inputs fields in the task initialisation
# (if not specified, will try to choose a sensible value)
convergence_threshold: 1e-6
n_iterations: '[50,50,30,20]'
input_image:
save_bias: 'False'
copy_header: 'False'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand All @@ -205,6 +211,10 @@ tests:
# dict[str, str] - values to provide to inputs fields in the task initialisation
# (if not specified, will try to choose a sensible value)
bspline_order: '5'
bspline_fitting_distance: 10
save_bias: 'False'
copy_header: 'False'
input_image:
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand All @@ -225,6 +235,7 @@ tests:
# (if not specified, will try to choose a sensible value)
input_image:
save_bias: 'True'
copy_header: 'False'
dimension: '3'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
Expand All @@ -247,6 +258,8 @@ tests:
input_image:
dimension: '3'
histogram_sharpening: (0.12, 0.02, 200)
save_bias: 'False'
copy_header: 'False'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand Down Expand Up @@ -274,6 +287,8 @@ doctests:
bspline_fitting_distance: '300'
shrink_factor: '3'
n_iterations: '[50,50,30,20]'
save_bias: 'False'
copy_header: 'False'
imports: *id001
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand All @@ -286,6 +301,9 @@ doctests:
# If the field is of file-format type and the value is None, then the
# '.mock()' method of the corresponding class is used instead.
convergence_threshold: 1e-6
n_iterations: '[50,50,30,20]'
save_bias: 'False'
copy_header: 'False'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand All @@ -298,6 +316,8 @@ doctests:
# If the field is of file-format type and the value is None, then the
# '.mock()' method of the corresponding class is used instead.
bspline_order: '5'
save_bias: 'False'
copy_header: 'False'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
Expand All @@ -311,6 +331,7 @@ doctests:
# '.mock()' method of the corresponding class is used instead.
input_image:
save_bias: 'True'
copy_header: 'False'
dimension: '3'
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
Expand All @@ -324,6 +345,8 @@ doctests:
# If the field is of file-format type and the value is None, then the
# '.mock()' method of the corresponding class is used instead.
input_image:
save_bias: 'False'
copy_header: 'False'
dimension: '3'
histogram_sharpening: (0.12, 0.02, 200)
imports:
Expand Down
7 changes: 6 additions & 1 deletion nipype2pydra/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from pathlib import Path
from fileformats.core import FileSet

try:
from typing import GenericAlias
except ImportError:
from typing import _GenericAlias as GenericAlias

from importlib import import_module


Expand Down Expand Up @@ -70,7 +75,7 @@ def add_to_sys_path(path: Path):
def is_fileset(tp: type):
return (
inspect.isclass(tp)
and type(tp) is not ty.GenericAlias
and type(tp) is not GenericAlias
and issubclass(tp, FileSet)
)

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test = [
"pytest >=6.2.5",
"pytest-env>=0.6.2",
"pytest-cov>=2.12.1",
"fileformats-medimage-extras",
]
docs = [
"packaging",
Expand Down
4 changes: 1 addition & 3 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import yaml
from conftest import show_cli_trace
import pytest
import shutil
import logging
from nipype2pydra.cli import task as task_cli
from nipype2pydra.utils import add_to_sys_path
Expand All @@ -18,7 +17,6 @@
"trait_modified",
"environ",
"output_type",
"crop_list",
]


Expand Down Expand Up @@ -48,7 +46,7 @@ def test_task_conversion(task_spec_file, cli_runner, work_dir, gen_test_conftest
pydra_module = import_module(output_module_path)
pydra_task = getattr(pydra_module, task_spec["task_name"])
nipype_interface = getattr(
import_module(task_spec["nipype_module"]), task_spec["task_name"]
import_module(task_spec["nipype_module"]), task_spec["nipype_name"]
)

nipype_trait_names = nipype_interface.input_spec().all_trait_names()
Expand Down