Skip to content

Commit 64317f4

Browse files
committed
add convert subgroup for boutiques
1 parent 8207421 commit 64317f4

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

nipype/scripts/cli.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
UNKNOWN_OPTIONS,
99
ExistingDirPath,
1010
ExistingFilePath,
11+
UnexistingFilePath,
1112
RegularExpression,
1213
PythonModule,
1314
grouper)
@@ -142,25 +143,18 @@ def run(ctx, module, interface, list, help):
142143
run_instance(node, args)
143144

144145

145-
# @cli.command(context_settings=UNKNOWN_OPTIONS)
146-
# @click.option('-f', '--format', type=click.Choice(['boutiques']),
147-
# help='Output format type.')
148-
# @click.argument('format_args', nargs=-1, type=click.UNPROCESSED)
149-
# @click.pass_context
150-
# def convert(ctx, format, format_args):
151-
# """Export nipype interfaces to other formats."""
152-
# if format == 'boutiques':
153-
# ctx.params.pop('format')
154-
# ctx.params = dict(grouper(ctx.params['format_args'], 2))
155-
# ctx.forward(to_boutiques)
146+
@cli.group()
147+
def convert():
148+
"""Export nipype interfaces to other formats."""
149+
pass
156150

157151

158-
@cli.command(context_settings=CONTEXT_SETTINGS)
152+
@convert.command(context_settings=CONTEXT_SETTINGS)
159153
@click.option("-i", "--interface", type=str, required=True,
160154
help="Name of the Nipype interface to export.")
161155
@click.option("-m", "--module", type=PythonModule(), required=True,
162156
help="Module where the interface is defined.")
163-
@click.option("-o", "--output", type=str, required=True,
157+
@click.option("-o", "--output", type=UnexistingFilePath, required=True,
164158
help="JSON file name where the Boutiques descriptor will be written.")
165159
@click.option("-t", "--ignored-template-inputs", type=str, multiple=True,
166160
help="Interface inputs ignored in path template creations.")
@@ -172,10 +166,10 @@ def run(ctx, module, interface, list, help):
172166
help="Ignore all numbers in path template creations.")
173167
@click.option("-v", "--verbose", is_flag=True, flag_value=True,
174168
help="Enable verbose output.")
175-
def to_boutiques(interface, module, output, ignored_template_inputs,
176-
docker_image, docker_index, ignore_template_numbers,
177-
verbose):
178-
"""Nipype Boutiques exporter.
169+
def boutiques(interface, module, output, ignored_template_inputs,
170+
docker_image, docker_index, ignore_template_numbers,
171+
verbose):
172+
"""Nipype to Boutiques exporter.
179173
180174
See Boutiques specification at https://github.com/boutiques/schema.
181175
"""

nipype/scripts/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# specification of existing ParamTypes
2222
ExistingDirPath = click.Path(exists=True, file_okay=False, resolve_path=True)
2323
ExistingFilePath = click.Path(exists=True, dir_okay=False, resolve_path=True)
24+
UnexistingFilePath = click.Path(dir_okay=False, resolve_path=True)
2425

2526

2627
# declare custom click.ParamType
@@ -37,7 +38,7 @@ def convert(self, value, param, ctx):
3738

3839

3940
class PythonModule(click.ParamType):
40-
name = 'Python module'
41+
name = 'Python module path'
4142

4243
def convert(self, value, param, ctx):
4344
try:

0 commit comments

Comments
 (0)