HenrikBengtsson / doFuture

:rocket: R package: doFuture - Use Foreach to Parallelize via Future Framework
https://doFuture.futureverse.org
84 stars 6 forks source link

Add/Register `info()` function for foreach getDoPar*() functions #1

Closed HenrikBengtsson closed 8 years ago

HenrikBengtsson commented 8 years ago

Currently the following returns NULL (default):

getDoParWorkers()
getDoParName()
getDoParVersion()

How to

> getDoParName
function ()
{
    if (exists("info", where = .foreachGlobals, inherits = FALSE))
        .foreachGlobals$info(.foreachGlobals$data, "name")
    else NULL
}
<environment: namespace:foreach>
> getDoParVersion
function ()
{
    if (exists("info", where = .foreachGlobals, inherits = FALSE))
        .foreachGlobals$info(.foreachGlobals$data, "version")
    else NULL
}
<environment: namespace:foreach>
> getDoParWorkers
function ()
{
    wc <- if (exists("info", where = .foreachGlobals, inherits = FALSE))
        .foreachGlobals$info(.foreachGlobals$data, "workers")
    else NULL
    if (is.null(wc))
        1L
    else wc
}
<environment: namespace:foreach>
HenrikBengtsson commented 8 years ago

getDoParName() and getDoParVersion() supported, cf. commit fc4431ee.

getDoParWorkers() should depend on the current future strategy, i.e type of futures used. For most, it will be possible to infer this, but what about BatchJobs futures? For instance, if the backend is a HPC cluster with a job scheduler, then how many workers are there?!? Is it ok to return +Inf?