grst / nxfvars

Access nextflow variables from python scripts or notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing parameters explicitly

grst opened this issue · comments

I came to think that it might be not a good idea to write every variable nxfvars can get programmatic access to to the .params.yml.

This is prone to unexpected InvocationTargetExceptions and causes issues like #6.

Instead, I could do

script:
"""
${nxfvars(cpus=task.cpus, in_dir=in_dir, out_dir=out_dir)}
execute_notebook.sh
"""

This could be further simplified by including the render command into the nxfvars function, e.g.

script:
"""
${nxfvars_rmd('notebook.Rmd', cpus: task.cpus, in_dir: in_dir, out_dir: out_dir)}
"""

Maybe it even works to do

script:
nxfvars_rmd('notebook.Rmd', cpus: task.cpus, in_dir: in_dir, out_dir: out_dir)

then.

Then again, is that a lot better compared to

papermill notebook.ipynb \\
   -p cpus ${task.cpus} \\
   -p in_dir ${in_dir} \\
   -p out_dir ${out_dir}

One advantage would still be that by writing the yaml file it is possible to dump entire lists or maps.