Closed mzganec closed 7 years ago
Inserting " instead of an empty list [] when an input is not specified is incorrect
Why? If an input is not specified, it is None
(or undefined), not a default-constructed type. I find this behavior correct. Otherwise we need to specify default
for each input field.
Consequently a Jinja2 check {% if not genes %} in the run section of the process behaves incorrectly as well
Can you elaborate on that? If the input is not set, not genes
should evaluate to True
. Are you saying that it evaluates to False
?
If an input is not specified, it is
None
(or undefined), not a default-constructed type.
If you print it out, for example with re-error
as above, you get "
. I was expecting to get []
.
If the input is not set,
not genes
should evaluate toTrue
. Are you saying that it evaluates toFalse
?
It evaluates to False
if this input is not specified in the input
dictionary of the run
method, because its value is incorrectly set to "
. If this input is specified as []
in the input
dictionary of the run
method, it evaluates to True
.
Printing a value as a string will automatically perform shell quoting. This does not mean that the actual value contains quotes, only if you try to print it it will be quoted before being printed. For that reason other expressions (like not genes
) should not be affected as genes
is not actually ''
.
Can you prepare a test process containing an if expression, which produces incorrect results when no inputs are passed? So without any printing, just an if expression which does exit 1
when incorrect and exit 0
when correct. Then I can reproduce the issue and see what the problem is.
This works correctly as you suggested. Thanks! Closing.
A process
called from resdk by specifying an empty set
[]
forgenes
inputres.run('test-list2', input={'genes': []}, collections=[6])
correctly returnsGenes: 1[]2
.If, however, you call the process by omitting the
genes
inputres.run('test-list2', input={}, collections=[6])
you getGenes: 1"2
. Inserting"
instead of an empty list[]
when an input is not specified is incorrect.Consequently a Jinja2 check
{% if not genes %}
in therun
section of the process behaves incorrectly as well.