looper icon indicating copy to clipboard operation
looper copied to clipboard

Idea: hierarchy of var_templates

Open nsheff opened this issue 4 years ago • 1 comments

Right now we have var_templates in the pipeline interface, which populates jinja templates. These are useful to provide parameters to plugins, but the names can potentially clash since they're not namespaced by plugin.

I propose that var templates should accept a hierarchy, so I can do somethign like:

var_templates:
  refgenie_plugin:
    config_path: "..."
  custom_template_plugin:
     config_path: "..."

As is, two plugins can't have the same parameter name, which isn't ideal.

nsheff avatar Jun 22 '21 21:06 nsheff

@donaldcampbelljr you've been looking at var_templates recently; what do you think of this feature proposal?

nsheff avatar Apr 24 '23 20:04 nsheff

Looking into this issue, I had to remind myself what are var_templates. The documentation exists but is sparse and without concrete examples. Hello Looper has a couple of pipeline interfaces that use them but they are not highlighted anywhere in the documentation.

As a reminder, here are two pipeline_interfaces:

Example using var_templates:

pipeline_name: example_pipeline  
pipeline_type: sample   
output_schema: output_schema.yaml  
var_templates:  
  path: "{looper.piface_dir}/pipelines/pipeline1.py"  
command_template: >  
  {pipeline.var_templates.path} --sample-name {sample.sample_name} --req-attr {sample.attr} 

Without using var_templates:

pipeline_name: example_pipeline  
pipeline_type: sample  
output_schema: output_schema.yaml  
command_template: >  
  python {looper.piface_dir}/count_lines.py {sample.file} {sample.sample_name} {pipestat.results_file}

We would like to enable hierarchy to var_templates such that we could do something like:

var_templates:
    my_plugin:
        path: "{looper.piface_dir}/pipelines/pipeline1.py"  
command_template: >  
  {pipeline.var_templates.my_plugin.path} --sample-name {sample.sample_name} --req-attr {sample.attr} 

donaldcampbelljr avatar Jun 05 '24 19:06 donaldcampbelljr

I have this working in https://github.com/pepkit/looper/pull/502

donaldcampbelljr avatar Jun 18 '24 16:06 donaldcampbelljr

I've added recursive functions to expand and render the var_templates so the user can nest them more than 2 levels if they desire.

donaldcampbelljr avatar Jun 19 '24 14:06 donaldcampbelljr