From 9bef9fce16a03a286a03bc176459994ef7198283 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 13:25:43 +1100 Subject: [PATCH 1/6] added and started to debug pkg gen --- nipype2pydra/pkg_gen/__init__.py | 1 + nipype2pydra/tests/test_pkg_gen.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 nipype2pydra/tests/test_pkg_gen.py diff --git a/nipype2pydra/pkg_gen/__init__.py b/nipype2pydra/pkg_gen/__init__.py index 8bcb2fcf..cca47dbd 100644 --- a/nipype2pydra/pkg_gen/__init__.py +++ b/nipype2pydra/pkg_gen/__init__.py @@ -563,6 +563,7 @@ def _fields_stub(cls, name, category_class, values=None): def download_tasks_template(output_path: Path): """Downloads the latest pydra-template to the output path""" + output_path.parent.mkdir(parents=True, exist_ok=True) release_url = ( "https://api.github.com/repos/nipype/pydra-tasks-template/releases/latest" diff --git a/nipype2pydra/tests/test_pkg_gen.py b/nipype2pydra/tests/test_pkg_gen.py new file mode 100644 index 00000000..0c253c39 --- /dev/null +++ b/nipype2pydra/tests/test_pkg_gen.py @@ -0,0 +1,20 @@ +from nipype2pydra.cli.pkg_gen import pkg_gen +from conftest import show_cli_trace + + +def test_pkg_gen(cli_runner, tmp_path): + outputs_dir = tmp_path / "output-dir" + examples_dir = tmp_path / "export-dir" + outputs_dir.mkdir() + + result = cli_runner( + pkg_gen, + [ + str(outputs_dir), + "--work-dir", + str(tmp_path / "work-dir"), + "--example-packages", + str(examples_dir), + ], + ) + assert result.exit_code == 0, show_cli_trace(result) From 9d705be82b6ed3b9e4c080b239973bb449eb0f65 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 15:47:47 +1100 Subject: [PATCH 2/6] touch up test for package generation --- nipype2pydra/tests/test_pkg_gen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nipype2pydra/tests/test_pkg_gen.py b/nipype2pydra/tests/test_pkg_gen.py index 0c253c39..5b92c708 100644 --- a/nipype2pydra/tests/test_pkg_gen.py +++ b/nipype2pydra/tests/test_pkg_gen.py @@ -6,6 +6,7 @@ def test_pkg_gen(cli_runner, tmp_path): outputs_dir = tmp_path / "output-dir" examples_dir = tmp_path / "export-dir" outputs_dir.mkdir() + examples_dir.mkdir() result = cli_runner( pkg_gen, From 5b338ce69a8fcfa7a381a78fbefc2d6f07f0d7e7 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 15:59:47 +1100 Subject: [PATCH 3/6] updated location of to_mime within fileformats package --- nipype2pydra/pkg_gen/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nipype2pydra/pkg_gen/__init__.py b/nipype2pydra/pkg_gen/__init__.py index cca47dbd..d9493b86 100644 --- a/nipype2pydra/pkg_gen/__init__.py +++ b/nipype2pydra/pkg_gen/__init__.py @@ -13,7 +13,7 @@ from operator import itemgetter import yaml import black.parsing -import fileformats.core.utils +import fileformats.core import fileformats.core.mixin from fileformats.generic import File, Directory from fileformats.medimage import Nifti1, NiftiGz, Bval, Bvec @@ -261,7 +261,7 @@ def generate_yaml_spec(self) -> str: def type2str(tp): if tp in non_mime: return tp.__name__ - return fileformats.core.utils.to_mime(tp, official=False) + return fileformats.core.to_mime(tp, official=False) tests, doctests = self._gen_tests( doctest_blocks, input_types, output_types, output_templates From d35efd847fb2669199ee67164bff26bc12390ac7 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 17:16:26 +1100 Subject: [PATCH 4/6] added check for isclass before checking for sub-classes --- nipype2pydra/pkg_gen/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nipype2pydra/pkg_gen/__init__.py b/nipype2pydra/pkg_gen/__init__.py index d9493b86..dfb411e0 100644 --- a/nipype2pydra/pkg_gen/__init__.py +++ b/nipype2pydra/pkg_gen/__init__.py @@ -7,6 +7,7 @@ import shutil import string from pathlib import Path +import inspect import attrs from warnings import warn import requests @@ -481,9 +482,10 @@ def combine_types(type_, prev_type): if ty.get_origin(type_) is list: as_list = True type_ = ty.get_args(type_)[0] - if issubclass(type_, prev_type): + both_classes = inspect.isclass(type_) and inspect.isclass(prev_type) + if both_classes and issubclass(type_, prev_type): combined = type_ - elif issubclass(prev_type, type_): + elif both_classes and issubclass(prev_type, type_): combined = prev_type else: if ty.get_origin(prev_type) is ty.Union: From 04a2c600653c4c9aed83fe28d94a65718bd68a85 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 17:54:02 +1100 Subject: [PATCH 5/6] configure git in GH action --- .github/workflows/ci-cd.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b508d6f8..7c688ac9 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -31,7 +31,11 @@ jobs: - name: Unset header # checkout@v2 adds a header that makes branch protection report errors # because the Github action bot is not a collaborator on the repo - run: git config --local --unset http.https://github.com/.extraheader + run: | + git config --local --unset http.https://github.com/.extraheader + git config --global init.defaultBranch main + git config --global user.email "dummy@email.com" + git config --global user.name "Dummy User" - name: Fetch tags run: git fetch --prune --unshallow From 0694d7b9e733063a55f73a43a06810b4ed01ff92 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Sat, 16 Mar 2024 18:20:35 +1100 Subject: [PATCH 6/6] stripped out examples dir --- nipype2pydra/tests/test_pkg_gen.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nipype2pydra/tests/test_pkg_gen.py b/nipype2pydra/tests/test_pkg_gen.py index 5b92c708..61c99bb6 100644 --- a/nipype2pydra/tests/test_pkg_gen.py +++ b/nipype2pydra/tests/test_pkg_gen.py @@ -4,9 +4,7 @@ def test_pkg_gen(cli_runner, tmp_path): outputs_dir = tmp_path / "output-dir" - examples_dir = tmp_path / "export-dir" outputs_dir.mkdir() - examples_dir.mkdir() result = cli_runner( pkg_gen, @@ -14,8 +12,6 @@ def test_pkg_gen(cli_runner, tmp_path): str(outputs_dir), "--work-dir", str(tmp_path / "work-dir"), - "--example-packages", - str(examples_dir), ], ) assert result.exit_code == 0, show_cli_trace(result)