Skip to content

[R-pkg-devel] [External] Guidelines on use of snow-style clusters in R packages?

2 messages · iuke-tier@ey m@iii@g oii uiow@@edu, Ivan Krylov

#
The basic principle I would follow is to make sure your code only goes
parallel with explicit permission from the end user. One way to do
that is accept a cluster from the caller; another is to create
and shut down your won cluster if a global option is set (via options()
or a mechanism of your own).

If you create and shut down your own cluster you can do pretty much
what you like. If you use one passed to you it would be best to leave
it in the state you found it at least as far as the search path and
global environment are concerned. So use foo::bar instead of library().

User can also set a default cluster. You can use getDefaultCluster to
retrieve it; this returns NULL if no default cluster is set.  You
could assume that if one is set you are allowed to use it, but it
might still be a good idea to look for explicit permission via an
option or an argument. I would again try to leave the cluster used
this way in as clean a state as you can.

Best,

luke
On Sun, 24 May 2020, Ivan Krylov wrote:

            

  
    
9 days later
#
On Wed, 3 Jun 2020 08:54:56 -0500 (CDT)
luke-tierney at uiowa.edu wrote:

            
Thanks for this advice! I guess that clusterExport() is also out of
question in package code, then.
I have found out that R Internals documents serialize() to use a very
efficient representation for package environments (a pseudo-SEXPTYPE
followed by the name). Does it mean that it is a good idea to pass
unexported private worker functions to parLapply(cl, X, fun), since the
package environment is not sent over network?