pydra icon indicating copy to clipboard operation
pydra copied to clipboard

ShellCommandTask subclasses not wroking with container_info

Open JeffWigger opened this issue 4 years ago • 0 comments

What version of Pydra are you using? 0.15

What were you trying to do? I wrote a subclass of ShellCommandTask and wanted to run it inside a Docker image by providing the container_info argument.

What did you expect will happen? I expected the command parsed by the ShellCommandTask subclass to be run inside the docker image.

What actually happened? Providing the container_info argument to my subclass resulted in only the parent class ShellCommandTask being initialized. As a result no command at all was run in the Docker image.

The following class demonstrates the issue:

from pydra.engine import specs
from pydra import ShellCommandTask

input_fields = [
    (
        "dir_name",
        str,
        {
            "help_string": "name of the directory to be created",
            "position":1, "argstr": "{dir_name}", "output_file_template": "{dir_name}"
        },
    ),
]
MkdirNew_input_spec = specs.SpecInfo(
    name="Input", fields=input_fields, bases=(specs.ShellSpec,)
)
class MkdirNew(ShellCommandTask):
    
    def __init__(
        self,
        name,
        **kwargs,
    ):
        input_spec = MkdirNew_input_spec
        output_spec = None
        executable = "mkdir"
        print("MkdirNew")
        super().__init__(
                    name=name,
                    input_spec=input_spec,
                    output_spec=output_spec,
                    executable=executable,
                    **kwargs,
                )

These are the results of using the above class:

$ mkdir = MkdirNew(name = "mkdir", dir_name = "test")

MkdirNew

$ mkdir()

Result(output=Output(return_code=0, stdout='', stderr='', dir_name=PosixPath('/tmp/tmpuyviw3us/MkdirNew_baee19ce7bcc647852ced788c9230cc09f2bf03a2499a420924afc43fac9efa7/test')), runtime=None, errored=False)

$ mkdir.cmdline

'mkdir test'

$ mkdir = MkdirNew(name = "mkdir", dir_name = "test", container_info=("docker", "busybox"))

$ mkdir()

Result(output=Output(return_code=0, stdout='', stderr=''), runtime=None, errored=False)

$ mkdir.cmdline

'docker run --rm -v /tmp/tmpgnb2y6q_/DockerTask_f9c0a8730fa061b80c677d09a67eb370a8464c72d1f1d4b28f598f320ce09a73:/output_pydra:rw -w /output_pydra busybox'

JeffWigger avatar May 21 '21 12:05 JeffWigger