mllg / batchtools

Tools for computation on batch systems
https://mllg.github.io/batchtools/
GNU Lesser General Public License v3.0
171 stars 51 forks source link

DISCUSSION: Alt path for template & config files via `R_BATCHTOOLS_SEARCH_PATH`? #155

Closed HenrikBengtsson closed 6 years ago

HenrikBengtsson commented 6 years ago

I ran into a interesting use case where I am not in full control of what the current working directory is when launching batchtools jobs (it's in an R temporary folder of spawned R process that is spawned by yet another R process). This prevents me from using a batchtools.{name}.tmpl in the working directory (of the grandparent R process). The only solution found was to use a user-account global template file, e.g. ~/.batchtools.{name}.tmpl.

Would it make sense to add R_BATCHTOOLS_SEARCH_PATH (env var that I can control) to the search path where batchtools:::findTemplateFile() looks for batchtools.{name}.tmpl? The same idea / question could then be applied to batchtools:::findConfFile() as well.

mllg commented 6 years ago

How about this:

If R_BATCHTOOLS_TEMPLATE is set, exactly this template will be used in findTemplateFile(). If R_BATCHTOOLS_CONFIG is set, exactly this file will be used in findConfFile().

Is there a use case where setting the search path has a benefit?

HenrikBengtsson commented 6 years ago

That works too.

The only reason why I propose R_BATCHTOOLS_SEARCH_PATH was that the advantage with a search path is that it's invariant to the type of scheduler (the {{name}}) part so that the latter only has to be specified in one place. With R_BATCHTOOLS_TEMPLATE you have to specify {{name}} in both the env var and the R code. The disadvantage with R_BATCHTOOLS_SEARCH_PATH is that it's not clear whether it should look for batchtools.{name}.tmpl or .batchtools.{name}.tmpl.

The advantages with R_BATCHTOOLS_TEMPLATE and R_BATCHTOOLS_CONFIG are that then those files can be located in different folders and it is more straightforward to explain what they do.

mllg commented 6 years ago

Does #156 work for you?

HenrikBengtsson commented 6 years ago

Awesome. That looks great.