From 8ea42c9b62b91bfd4d54159c4d68bf83aa7b42b0 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 2 Nov 2023 12:07:33 +1100 Subject: [PATCH 1/3] stopped converting task names to snake case --- scripts/pkg_gen/create_packages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pkg_gen/create_packages.py b/scripts/pkg_gen/create_packages.py index b79be4b1..3f0952f7 100644 --- a/scripts/pkg_gen/create_packages.py +++ b/scripts/pkg_gen/create_packages.py @@ -315,7 +315,7 @@ def combine_types(type_, prev_type): } spec_stub = { - "task_name": to_snake_case(interface), + "task_name": interface, "nipype_name": interface, "nipype_module": nipype_module_str, "inputs": fields_stub( From d65b78492fdaf94b4c5956881391fb65be6a4e38 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 2 Nov 2023 12:07:33 +1100 Subject: [PATCH 2/3] fixed up 3.8 incompatibility and formatted create_packages --- scripts/pkg_gen/create_packages.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/scripts/pkg_gen/create_packages.py b/scripts/pkg_gen/create_packages.py index 3f0952f7..8b1a0c2c 100644 --- a/scripts/pkg_gen/create_packages.py +++ b/scripts/pkg_gen/create_packages.py @@ -67,8 +67,10 @@ def download_tasks_template(output_path: Path): @click.option("--task-template", type=click.Path(path_type=Path), default=None) @click.option("--packages-to-import", type=click.Path(path_type=Path), default=None) def generate_packages( - output_dir: Path, work_dir: ty.Optional[Path], task_template: ty.Optional[Path], - packages_to_import: ty.Optional[Path] + output_dir: Path, + work_dir: ty.Optional[Path], + task_template: ty.Optional[Path], + packages_to_import: ty.Optional[Path], ): if work_dir is None: work_dir = Path(tempfile.mkdtemp()) @@ -82,7 +84,9 @@ def generate_packages( task_template = extract_dir / next(extract_dir.iterdir()) if packages_to_import is None: - packages_to_import = Path(__file__).parent.parent.parent / "nipype-interfaces-to-import.yaml" + packages_to_import = ( + Path(__file__).parent.parent.parent / "nipype-interfaces-to-import.yaml" + ) with open(packages_to_import) as f: to_import = yaml.load(f, Loader=yaml.SafeLoader) @@ -368,10 +372,18 @@ def combine_types(type_, prev_type): ) # Add comments to input and output fields, with their type and description for inpt, desc in input_helps.items(): - yaml_str = re.sub(f" ({inpt}):(.*)", r" \1:\2\n # ##PLACEHOLDER##", yaml_str) + yaml_str = re.sub( + f" ({inpt}):(.*)", + r" \1:\2\n # ##PLACEHOLDER##", + yaml_str, + ) yaml_str = yaml_str.replace("##PLACEHOLDER##", desc) for outpt, desc in output_helps.items(): - yaml_str = re.sub(f" ({outpt}):(.*)", r" \1:\2\n # ##PLACEHOLDER##", yaml_str) + yaml_str = re.sub( + f" ({outpt}):(.*)", + r" \1:\2\n # ##PLACEHOLDER##", + yaml_str, + ) yaml_str = yaml_str.replace("##PLACEHOLDER##", desc) with open(spec_dir / (spec_name + ".yaml"), "w") as f: @@ -546,7 +558,7 @@ def parse_nipype_interface( def extract_doctest_inputs( doctest: str, interface: str ) -> ty.Tuple[ - ty.Optional[str], dict[str, ty.Any], ty.Optional[str], ty.List[ty.Dict[str, str]] + ty.Optional[str], ty.Dict[str, ty.Any], ty.Optional[str], ty.List[ty.Dict[str, str]] ]: """Extract the inputs passed to tasks in the doctests of Nipype interfaces From c93922f22783d170df0d52c1f3aa72473f5442ea Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 2 Nov 2023 12:07:33 +1100 Subject: [PATCH 3/3] strip out all nipype imports --- nipype2pydra/task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype2pydra/task.py b/nipype2pydra/task.py index f6449790..9ee053a8 100644 --- a/nipype2pydra/task.py +++ b/nipype2pydra/task.py @@ -767,7 +767,7 @@ def add_import(stmt): add_import("from pathlib import Path") for test in self.tests: for stmt in test.imports: - if stmt.module.startswith("nipype.testing"): + if "nipype" in stmt.module: continue if stmt.name is None: add_import(f"import {stmt.module}")