8000 Proper way to format a tuple parameter · Issue #613 · nipype/pydra · GitHub
[go: up one dir, main page]

Skip to content
Proper way to format a tuple parameter #613
@ghisvail

Description

@ghisvail

I have got an interface which expects a parameter foo as a triple with the following format --foo 1 2 3

I reached for the following definition as a first attempt:

input_spec = pydra.specs.SpecInfo(
    name="Input",
    fields=[
        (
            "foo",
            ty.Tuple[int, int, int],
            {
                "help_string": "foo triple",
                "argstr": "--foo {foo}",
            },
        ),
    ],
    bases=(pydra.specs.ShellSpec,),

Which does not work since it produces --foo (1, 2, 3).

If I use --foo... and instantiate the interface with a list instead of tuple then I get --foo 1 --foo 2 --foo 3.

If I use formatter instead of argstr with "formatter": lambda field: f"--foo {' '.join(field)}", I get an error because formatter seem to be called with each element of the list instead of the entire list (TypeError: sequence item 0: expected str instance, int found).

I am probably missing another option, hence this support request 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0