Hi, I'm wondering how optional arguments should be...
# modules
l
Hi, I'm wondering how optional arguments should be given for a template script. In some place it is done as passing the
task.ext.my_args
but this does not fit with the
task.ext.args
that we use in all the other modules. Also this way this argument is not referenced in the meta.yaml. I see three possibility: 1. Continue using
task.ext.my_args
2. Use
tast.ext.args
with flag (more complicated to parse) or use a python argument parser 3. Set all the argument as value channel even the optional one (+ description in meta.yml) What do you think ?
m
Can you give an example of what you mean? I'm not clear what the complication is. Usually you're doing:
Copy code
script:
args = task.ext.args ?: ""
prefix = task.ext.prefix ?: meta.id
template 'some_script.py'
and then
args
is used as a string in the script, as an
input:
would. You can then do stuff with
shlex.split()
, or however you want to deal with it since the other input variables are also embedded in the template.
l
That's an issue we have with different python modules For example in
CELLBENDER_MERGE
:
Copy code
script:
    prefix = task.ext.prefix ?: "${meta.id}"
    output_layer = task.ext.output_layer ?: "cellbender"
    template 'merge.py'
m
Are you referring to
output_layer
? I would treat that as a
input:
because looks like a required value where you provide a default.
l
I totally agree, this is an issue I saw while reviewing different PR on the modules repository.