diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 966c601d..0eef3f5e 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 diff --git a/nipype2pydra/pkg_gen/__init__.py b/nipype2pydra/pkg_gen/__init__.py index 8bcb2fcf..dfb411e0 100644 --- a/nipype2pydra/pkg_gen/__init__.py +++ b/nipype2pydra/pkg_gen/__init__.py @@ -7,13 +7,14 @@ import shutil import string from pathlib import Path +import inspect import attrs from warnings import warn import requests 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 +262,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 @@ -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: @@ -563,6 +565,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..61c99bb6 --- /dev/null +++ b/nipype2pydra/tests/test_pkg_gen.py @@ -0,0 +1,17 @@ +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" + outputs_dir.mkdir() + + result = cli_runner( + pkg_gen, + [ + str(outputs_dir), + "--work-dir", + str(tmp_path / "work-dir"), + ], + ) + assert result.exit_code == 0, show_cli_trace(result)