Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d6ff89

Browse files
authored
Merge pull request #14 from nipype/pkg-gen-test
Add package generation test
2 parents ac0297d + 0694d7b commit 7d6ff89

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ jobs:
3131
- name: Unset header
3232
# checkout@v2 adds a header that makes branch protection report errors
3333
# because the Github action bot is not a collaborator on the repo
34-
run: git config --local --unset http.https://github.com/.extraheader
34+
run: |
35+
git config --local --unset http.https://github.com/.extraheader
36+
git config --global init.defaultBranch main
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "Dummy User"
3539
3640
- name: Fetch tags
3741
run: git fetch --prune --unshallow

nipype2pydra/pkg_gen/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
import shutil
88
import string
99
from pathlib import Path
10+
import inspect
1011
import attrs
1112
from warnings import warn
1213
import requests
1314
from operator import itemgetter
1415
import yaml
1516
import black.parsing
16-
import fileformats.core.utils
17+
import fileformats.core
1718
import fileformats.core.mixin
1819
from fileformats.generic import File, Directory
1920
from fileformats.medimage import Nifti1, NiftiGz, Bval, Bvec
@@ -261,7 +262,7 @@ def generate_yaml_spec(self) -> str:
261262
def type2str(tp):
262263
if tp in non_mime:
263264
return tp.__name__
264-
return fileformats.core.utils.to_mime(tp, official=False)
265+
return fileformats.core.to_mime(tp, official=False)
265266

266267
tests, doctests = self._gen_tests(
267268
doctest_blocks, input_types, output_types, output_templates
@@ -481,9 +482,10 @@ def combine_types(type_, prev_type):
481482
if ty.get_origin(type_) is list:
482483
as_list = True
483484
type_ = ty.get_args(type_)[0]
484-
if issubclass(type_, prev_type):
485+
both_classes = inspect.isclass(type_) and inspect.isclass(prev_type)
486+
if both_classes and issubclass(type_, prev_type):
485487
combined = type_
486-
elif issubclass(prev_type, type_):
488+
elif both_classes and issubclass(prev_type, type_):
487489
combined = prev_type
488490
else:
489491
if ty.get_origin(prev_type) is ty.Union:
@@ -563,6 +565,7 @@ def _fields_stub(cls, name, category_class, values=None):
563565

564566
def download_tasks_template(output_path: Path):
565567
"""Downloads the latest pydra-template to the output path"""
568+
output_path.parent.mkdir(parents=True, exist_ok=True)
566569

567570
release_url = (
568571
"https://api.github.com/repos/nipype/pydra-tasks-template/releases/latest"

nipype2pydra/tests/test_pkg_gen.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from nipype2pydra.cli.pkg_gen import pkg_gen
2+
from conftest import show_cli_trace
3+
4+
5+
def test_pkg_gen(cli_runner, tmp_path):
6+
outputs_dir = tmp_path / "output-dir"
7+
outputs_dir.mkdir()
8+
9+
result = cli_runner(
10+
pkg_gen,
11+
[
12+
str(outputs_dir),
13+
"--work-dir",
14+
str(tmp_path / "work-dir"),
15+
],
16+
)
17+
assert result.exit_code == 0, show_cli_trace(result)

0 commit comments

Comments
 (0)