Bioconductor / BiocParallel

Bioconductor facilities for parallel evaluation
https://bioconductor.org/packages/BiocParallel
67 stars 29 forks source link

Making register() a generic #104

Open LTLA opened 5 years ago

LTLA commented 5 years ago

BiocNeighbors and BiocSingular follow BiocParallel's paradigm of using *Param objects to specify the algorithm and parameters to use for NN searching and SVD, respectively.

I have recently added a BiocSingular::bsparam() function that returns a "default" Param object, in much the same way that BiocParallel::bpparam() works. The idea is that developers can specify bsparam() in their functions/scripts and it will use a global default value that can be changed by the user. This is more convenient than passing the new Param explicitly to each function.

Currently, I am using a global options() to handle this, but it would be nice to use the BiocParallel::register() interface (and its internal machinery) to manage the setting and getting of the global default. One could imagine making register() an S4 generic, or even better, adding a simple mechanism that allows my packages to save to a different slot of the existing registry.

DarwinAwardWinner commented 5 years ago

a simple mechanism that allows my packages to save to a different slot of the existing registry.

Wouldn't this effectively just be reimplementing options with maybe slightly different semantics? What would be the advantage register over options here?