HenrikBengtsson / doFuture

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

BUG: Expression generated for attaching packages is invalid(?) #2

Closed HenrikBengtsson closed 8 years ago

HenrikBengtsson commented 8 years ago

Although it seems to work, I believe the following generates an invalid syntax tree:

    exprs <- lapply(pkgs, FUN=function(pkg) {
      parse(text=sprintf('library("%s")', pkg))
    })
    exprs <- c(exprs, expr)
    expr <- Reduce(function(a, b) {
      substitute({ a; b }, list(a=a, b=b))
    }, x=exprs)

This needs to be fixed and release before future 1.1.0 is released, otherwise we get:

> library("doFuture")
> registerDoFuture()
> y <- foreach(i=1:3) %dopar% { i }
> y <- foreach(i=1:3, .packages="stats") %dopar% { i }
Error: Cannot walk expression. Unknown object type ‘expression’

> traceback()
12: stop("Cannot walk expression. Unknown object type ", sQuote(typeof(expr)), 
        call. = FALSE)
11: walkAST(expr[[cc]], atomic = atomic, name = name, call = call, 
        pairlist = pairlist, substitute = FALSE)
10: walkAST(expr, call = tweakFutureAssignmentCall)
9: tweak(expr)
8: findGlobals(expr, envir = envir, ..., method = method, tweak = tweak, 
       substitute = FALSE, unlist = unlist)
7: globalsOf(expr, envir = envir, substitute = FALSE, tweak = tweak, 
       dotdotdot = "return", method = globals.method, unlist = TRUE, 
       mustExist = mustExist)
6: getGlobalsAndPackages(expr, envir = envir, tweak = tweakExpression, 
       globals = globals, resolve = TRUE)
5: LazyFuture(expr = expr, envir = envir, local = local, globals = globals, 
       earlySignal = earlySignal)
4: evaluator(expr, envir = envir, substitute = FALSE, ...)
3: future(expr, substitute = FALSE, envir = env)
2: e$fun(obj, substitute(ex), parent.frame(), e$data)
1: foreach(i = 1:3, .packages = "stats") %dopar% {
       i
   }