PMCC-BioinformaticsCore / janis-core

Core python modules for Janis Pipeline workflow assistant
GNU General Public License v3.0
4 stars 9 forks source link

Quoting bug #43

Closed drtconway closed 4 years ago

drtconway commented 4 years ago

Consider the following command tool:

from janis_core import ToolInput, ToolArgument, ToolOutput, ToolMetadata, Array, Directory, String, InputSelector

from janis_core.operators.standard import JoinOperator
from janis_bioinformatics.tools.bioinformaticstoolbase import BioinformaticsTool

class RInstallPackages(BioinformaticsTool):
    def tool(self):
        return "RInstallPackages"

    def friendly_name(self):
        return "R-Install-Packages"

    def tool_provider(self):
        return "R"

    def container(self):
        return "r-base:latest"

    def version(self):
        return "4.0.2"

    def base_command(self):
        return ["R"]

    def inputs(self):
        return [
            ToolInput("packages", Array(String), position=1),
        ]

    def arguments(self):
        return [
            ToolArgument(
                "-e 'install.packages(\"" + JoinOperator(InputSelector("packages"), '", "') + "\")'",
                shell_quote=False
            )
        ]

    def outputs(self):
        return [ToolOutput("out", Directory, glob="/usr/local/lib/R/site-library")]

    def bind_metadata(self):
        from datetime import date

        return ToolMetadata(
            contributors=["Thomas Conway"],
            dateCreated=date(2020, 10, 13),
            dateUpdated=date(2020, 10, 13)
        )

And the invocation:

$ janis run -o qux pkginstall.py --packages data.table ggplot2

This should result in a workflow running the following command in an r-base container:

R -e 'install.packages("data.table", "ggplot2")'

Unfortunately it runs into quoting issues, with engine.log containing the following:

2020-10-13 02:35:29,647 cromwell-system-akka.dispatchers.engine-dispatcher-13 INFO  - WorkflowManagerActor Workflow b63691ac-eea3-4b7d-8238-568083a9e81c failed (during MaterializingWorkflowDescriptorState): cromwell.engine.workflow.lifecycle.materialization.MaterializeWorkflowDescriptorActor$$anon$1: Workflow input processing failed:
Unrecognized token on line 14, column 68:
      ~{(("-e 'install.packages("" + sep("", "", packages)) + "")'")} \
                                                                       ^
illusional commented 4 years ago

Thanks for the report, fixed in https://github.com/PMCC-BioinformaticsCore/janis-core/commit/5b34afd46c4f2ed311400c51a3c05c28afeca907.