yuch7 / cwlexec

A new open source tool to run CWL workflows on LSF
Other
36 stars 8 forks source link

Quotes not recognized in baseCommand #9

Open drjrm3 opened 6 years ago

drjrm3 commented 6 years ago

We have a simple workflow which uses baseCommand: [awk, '{print $2}'] and the interpreted command does not keep the ''s. Instead, it interprets the baseCommand as "baseCommand" : [ "awk", "{print $2}" ], (line 40 in the attached outfile.txt) and attempts to execute awk {print $2} (line 148) which fails. BaseCommandError.tar.gz

liuboxa commented 6 years ago

As a workaround, you can use double quotes (") to quote the command in baseCommand, e.g. baseCommand: ["awk", "'{print $2}'"]

In deed, this is a bug, we will fix it finally

drkennetz commented 6 years ago

Thanks for the response, this has been my workaround for the above example. However, if the awk command contains quotes itself: baseCommand: [awk, "'{$5=$6=$7=$8=""; print $0}'"] cwltool fails causing cwlexec to not even start the job (because the input failed validation). Syntax error while parsing a flow sequence File:///awkColumnDisplace.cwl", line 22, column 14 expected ',' or ']', but got '<scalar>'

liuboxa commented 6 years ago

@drkennetz and @drjrm3 cwlexec use jackson to parse the cwl definition/inputs files, but jackson doesn't seem to work very well when a field has the single quotes ('), so we suggest you use double quotes (") to quote the command options

https://github.com/FasterXML/jackson-core/pull/235 https://github.com/json-path/JsonPath/issues/275

@drkennetz For your case, you should escape the double quotes (") in your string, e.g. baseCommand: [awk, "'{$5=$6=$7=$8=\"\"; print $0}'"] This will work well

biokcb commented 6 years ago

Hello,

I am having a related issue, where having an input as a string type builds the command incorrectly. I have attached a simple case where there are 3 input examples given. The first two cause an error with my shell script because it expects only two fields.

message: hello world Expected out_1.txt: hello world Actual out_1.txt: Errors out because the input needs quotes

message: "hello world" Expected out_2.txt: hello world Actual out_2.txt: Errors out because the input needs quotes and cwlexec gets rid of them

message: "'hello world'" Expected out_3.txt: 'hello world' Actual out_3.txt: hello world

So the workaround given does get around the quotes issue and it will work, but the output is different than the expected output which causes reproducibility issues if I want to use the script with cwlexec and cwltool. Thanks!

StringQuotesError.tar.gz

skeeey commented 6 years ago

@biokcb Thanks for your cases, they are good cases for us, the quotes problem is more trick :( , but I think you may follow below rules:

message: hello world

equals

message: "hello world"

and equals

message: 'hello world'

all of above definitions will get a string that does not has any quotes (hello world)

If you want to define a string that has double quotes ("hello world"), you need define it to

message: '"hello world"'

or

message: "\"hello world\""

and if you want to define a string that has single quotes ('hello world'), you need define it to

message: "'hello world'"